1 #################################################################################
2 # Xestia Scanner Server Output Module - PNG Output Module. #
3 # Outputs the image into the PNG format. #
5 # Copyright (C) 2010-11 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
7 # This module is licensed under the same license as Xestia Scanner Server which #
8 # is licensed under the GPL version 3. #
10 # This program is free software: you can redistribute it and/or modify #
11 # it under the terms of the GNU General Public License as published by #
12 # the Free Software Foundation, version 3 of the License. #
14 # This program is distributed in the hope that it will be useful, #
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17 # GNU General Public License for more details. #
19 # You should have received a copy of the GNU General Public License #
20 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
21 #################################################################################
23 # Define the package (perl module) name.
25 package Modules::Output::PNG;
27 # Enable strict and use warnings.
31 use Encode qw(decode_utf8);
33 use Modules::System::Common;
36 # Set the following values.
38 our $VERSION = "0.1.0";
41 my $error_message = "";
42 my $language_name = "";
45 tie(%pages, "Tie::IxHash");
48 #################################################################################
49 # new: Create an instance of Modules::Output::Normal #
53 # $dbmodule = Modules::Output::Normal->new(); #
54 #################################################################################
56 # Get the perl module name.
61 return bless($self, $class);
66 #################################################################################
67 # initialise: Initialises the output module. #
71 # $outputmodule->initialise(); #
72 #################################################################################
77 #################################################################################
78 # loadsettings: Loads some settings for the output module. #
82 # $outputmodule->loadsettings(language); #
84 # language Specifies the language to use. #
85 #################################################################################
88 my $passed_lang = shift;
90 $language_name = $passed_lang;
95 #################################################################################
96 # getoptions: Gets the options that will be used. #
100 # %options = $outputmodule->getoptions(); #
101 #################################################################################
103 my (%options, $options);
104 tie(%options, "Tie::IxHash");
106 #$options{seperatedirdatabase}{type} = "checkbox";
107 #$options{seperatedirdatabase}{string} = "Disable content type (make browser guess!)";
113 #################################################################################
114 # errorflag: Returns an error flag (if any). #
118 # $errorflag = $outputmodule->errorflag(); #
119 #################################################################################
126 #################################################################################
127 # errormessage: Returns an error message (if any). #
131 # $errormessage = $outputmodule->errormessage(); #
132 #################################################################################
134 return $error_message;
139 #################################################################################
140 # clearflag: Clears the error message flag and the error message itself. #
144 # $outputmodule->clearflag(); #
145 #################################################################################
153 #################################################################################
154 # processimage: Processes the image. #
158 # $outputmodule->processimage(hexnumber, outputmoduleoptions); #
160 # hexnumber Specifies the hex number for the image. #
161 # outputmoduleoptions Specifies the options for the output module as a hash. #
162 #################################################################################
165 my $hexnumber = shift;
166 my $outputmoduleoptions = @_;
170 my $im = new Image::Magick;
171 $errmsg = $im->Read("/tmp/xestiascanserver-preview-" . $hexnumber . ".pnm");
176 $error_message = $errmsg;
181 $errmsg = $im->Write("/tmp/xestiascanserver-final-" . $hexnumber . ".png");
186 $error_message = $errmsg;
191 return "/tmp/xestiascanserver-final-" . $hexnumber . ".png";
196 #################################################################################
197 # languagestrings: Language strings that are used in this module. #
201 # $string = $outputmodule->languagestrings("langstring"); #
202 #################################################################################
204 my $langstring = shift;
207 my ($language_strings, %language_strings);
210 if ($language_name eq "en-GB" or !$language_name){
212 # Language strings for English (British) language.
214 $language_strings{seperatedirdatabase} = "Seperate directory for each database.";
215 $language_strings{invalidpermissionset} = "Invalid file permissions set.";
219 # Invalid language so use English (British) as default.
221 $language_strings{seperatedirdatabase} = "Seperate directory for each database.";
222 $language_strings{invalidpermissionset} = "Invalid file permissions set.";
226 $language_string = $language_strings{$langstring};
230 $language_string =~ s/%s/$item/;
234 return $language_string;