Changeset 16008 for gsdl/trunk/perllib/plugins
- Timestamp:
- 2008-06-16T11:11:44+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/ImageConverter.pm
r15881 r16008 4 4 5 5 use strict; 6 use gsprintf 'gsprintf'; 6 7 7 8 BEGIN { … … 11 12 my $arguments = [ 12 13 { 'name' => "create_thumbnail", 13 'desc' => "{ImageConverter.generatethumbnail}", 14 'type' => "bool", 14 'desc' => "{ImageConverter.create_thumbnail}", 15 'type' => "enum", 16 'list' => [{'name' => "true", 'desc' => "{ImageConverter.true}"}, 17 {'name' => "false", 'desc' => "{ImageConverter.false}"}], 15 18 'deft' => "true", 16 'reqd' => "no" },17 { 'name' => "noscaleup",18 'desc' => "{ImageConverter.noscaleup}",19 'type' => "flag",20 19 'reqd' => "no" }, 21 20 { 'name' => "thumbnailsize", … … 30 29 'deft' => "gif", 31 30 'reqd' => "no" }, 31 { 'name' => "noscaleup", 32 'desc' => "{ImageConverter.noscaleup}", 33 'type' => "flag", 34 'reqd' => "no" }, 32 35 { 'name' => "create_screenview", 33 'desc' => "{ImageConverter.generatescreenview}", 34 'type' => "bool", 36 'desc' => "{ImageConverter.create_screenview}", 37 'type' => "enum", 38 'list' => [{'name' => "true", 'desc' => "{ImageConverter.true}"}, 39 {'name' => "false", 'desc' => "{ImageConverter.false}"}], 35 40 'deft' => "true", 36 41 'reqd' => "no" }, … … 51 56 'deft' => "", 52 57 'reqd' => "no" }, 53 { 'name' => "noscaleup",54 'desc' => "{ImageConverter.noscaleup}",55 'type' => "flag",56 'reqd' => "no" },57 58 { 'name' => "minimumsize", 58 59 'desc' => "{ImageConverter.minimumsize}", … … 83 84 my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists, 1); 84 85 85 # Check that ImageMagick is installed and available on the path (except for Windows 95/98) 86 if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) { 86 return bless $self, $class; 87 88 } 89 90 # needs to be called after BasePlugin init, so that outhandle is set up. 91 sub init { 92 my $self = shift(@_); 93 94 $self->{'tmp_file_paths'} = (); 95 96 # Check that ImageMagick is installed and available on the path 97 my $image_conversion_available = 1; 98 my $no_image_conversion_reason = ""; 99 # None of this works very well on Windows 95/98... 100 if ($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT()) { 101 $image_conversion_available = 0; 102 $no_image_conversion_reason = "win95notsupported"; 103 } else { 87 104 my $result = `identify 2>&1`; 88 105 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found" 89 $self->{'imagemagick_not_installed'} = 1; 90 } 91 } 92 return bless $self, $class; 93 94 } 95 96 sub init { 97 my $self = shift(@_); 98 99 $self->{'tmp_file_paths'} = (); 100 } 101 102 sub check_imagemagick { 103 104 my $self = shift (@_); 105 my ($gli) = @_; 106 107 my $outhandle = $self->{'outhandle'}; 108 109 my $image_magick_ok = 1; 110 # None of this works very well on Windows 95/98... 111 if ($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT()) { 112 if ($gli) { 113 #print STDERR "<ProcessingError n='$file' r='Windows 95/98 not supported'>\n"; 114 # have no file here. other kind of error? just want a warning really 115 } 116 print $outhandle "ImageConverter: Windows 95/98 not supported, no image processing available\n"; 117 $image_magick_ok = 0; 118 119 } else { 120 # Check that ImageMagick is installed and available on the path 121 my $result = `identify 2>&1`; 122 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found" 123 if ($gli) { 124 #print STDERR "<ProcessingError n='$file' r='ImageMagick not installed'>\n"; 125 } 126 print $outhandle "ImageConverter: ImageMagick not installed, no image processing available\n"; 127 $image_magick_ok = 0; 128 } 129 } 130 return $image_magick_ok; 131 132 } 106 $image_conversion_available = 0; 107 $no_image_conversion_reason = "imagemagicknotinstalled"; 108 } 109 } 110 $self->{'image_conversion_available'} = $image_conversion_available; 111 $self->{'no_image_conversion_reason'} = $no_image_conversion_reason; 112 113 if ($self->{'image_conversion_available'} == 0) { 114 my $outhandle = $self->{'outhandle'}; 115 &gsprintf($outhandle, "ImageConverter: {ImageConverter.noconversionavailable} ({ImageConverter.".$self->{'no_image_conversion_reason'}."})\n"); 116 } 117 } 118 133 119 134 120 # convert image to new type if converttotype is set … … 141 127 my ($filename_full_path, $filename_no_path, $doc_obj, $section) = @_; 142 128 129 # check image magick status 130 return 0 if $self->{'image_conversion_available'} == 0; 143 131 # check the filenames 144 132 return 0 if ($filename_no_path eq "" || !-f $filename_full_path);
Note:
See TracChangeset
for help on using the changeset viewer.