Changeset 24600 for main/trunk/greenstone2
- Timestamp:
- 2011-09-15T16:31:11+12:00 (13 years ago)
- Location:
- main/trunk/greenstone2
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/bin/script/gsConvert.pl
r24513 r24600 824 824 # Check that ImageMagick is installed and available on the path (except for Windows 95/98) 825 825 if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) { 826 my $result = `identify 2>&1`; 827 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found" 826 my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl"; 827 my $result = `$imagick_cmd identify 2>&1`; 828 829 # Linux and Windows return different values for "program not found". 830 # Linux returns -1 and Windows 256 for "program not found". But once they're 831 # converted to signed values, it will be -1 for Linux and 1 for Windows. 832 # Whenever we test for return values other than 0, shift by 8 and perform 833 # unsigned to signed status conversion on $? to get expected range of return vals 834 # Although gs-magick.pl already shifts its $? by 8, converts it to a signed value 835 # and then exits on that, by the time we get here, we need to do it again 836 my $status = $?; 837 $status >>= 8; 838 $status = (($status & 0x80) ? -(0x100 - ($status & 0xFF)) : $status); 839 if ($status == -1 || $status == 1) { #if ($status == -1 || $status == 256) { 828 840 #ImageMagick is not installed, thus the convert utility is not available. 829 841 print STDERR "*** ImageMagick is not installed, the convert utility is not available. Unable to convert PDF/PS to images\n"; -
main/trunk/greenstone2/bin/script/pdfpstoimg.pl
r17328 r24600 88 88 # with quoting when GSDLHOME might contain spaces) but assume 89 89 # that the PATH is set up correctly. 90 $cmd = " convert";90 $cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert"; 91 91 92 92 my $output_filename = &util::filename_cat($output_filestem, $input_basename); … … 100 100 # note we return 0 if the file is "encrypted" 101 101 $!=0; 102 if (system($cmd)!=0) { 102 my $status = system($cmd); 103 if ($status != 0) { 103 104 print STDERR "Convert error for $input_filename $!\n"; 104 105 # leave these for gsConvert.pl... -
main/trunk/greenstone2/bin/script/pdftohtml.pl
r7643 r24600 249 249 $cmd = "pnmtopng \"${directory}$image\" > \"${directory}$image_base.png\" 2>/dev/null"; 250 250 if (system($cmd)!=0) { 251 $cmd = " convert \"${directory}$image\" \"${directory}$image_base.png\" 2>/dev/null";251 $cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert \"${directory}$image\" \"${directory}$image_base.png\" 2>/dev/null"; 252 252 if (system($cmd)!=0) { 253 253 print STDERR "Cannot convert $image into PNG format (tried `pnmtopng' and `convert')...\n"; -
main/trunk/greenstone2/perllib/cgiactions/imageaction.pm
r24597 r24600 29 29 30 30 use cgiactions::baseaction; 31 use util; 31 32 32 33 @imageaction::ISA = ('baseaction'); … … 158 159 159 160 160 my $cmd = " convert \"$src_full_assoc_filename\" ";161 my $cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert \"$src_full_assoc_filename\" "; 161 162 $cmd .= "-rotate 90 " if ($orientation eq "landscape"); 162 163 -
main/trunk/greenstone2/perllib/convertutil.pm
r22469 r24600 175 175 if ($command_status != 0) { 176 176 $had_error = 1; 177 178 print $outhandle "Error: processing command failed. Exit status $?\n"; 177 178 # for imagemagick commands that go via gs-magick.pl, need to shift exit code by 8 and then 179 # convert to its signed value to get the actual exit code that imagemagick had emitted. 180 my $signed_cmd_status = $command_status; 181 $signed_cmd_status >>= 8; 182 $signed_cmd_status = (($signed_cmd_status & 0x80) ? -(0x100 - ($signed_cmd_status & 0xFF)) : $signed_cmd_status); 183 184 print $outhandle "Error: processing command failed. Exit status $command_status (signed value: $signed_cmd_status)\n"; 179 185 180 186 if ($verbosity >= 3) { -
main/trunk/greenstone2/perllib/giget.pm
r15889 r24600 1 1 use strict; 2 use util; 2 3 3 4 … … 150 151 unlink $output_fname; 151 152 } 152 elsif (system("identify \"$output_fname\"") > 0 ) {153 print STDERR "**** NOT JPEG: output_fname \n";154 unlink $output_fname;155 }156 153 else { 157 158 my $command = "identify \"$output_fname\" 2>&1"; 159 my $result = `$command`; 160 161 my $type = 'unknown'; 162 my $width = 'unknown'; 163 my $height = 'unknown'; 164 165 my $image_safe = quotemeta $output_fname; 166 if ($result =~ /^$image_safe (\w+) (\d+)x(\d+)/) { 167 $type = $1; 168 $width = $2; 169 $height = $3; 154 # need to shift the $? exit code returned by system() by 8 bits and 155 # then convert it to a signed value to work out whether it is indeed > 0 156 my $status = system("\"".&util::get_perl_exec()."\" -S gs-magick.pl identify \"$output_fname\""); 157 $status >>= 8; 158 $status = (($status & 0x80) ? -(0x100 - ($status & 0xFF)) : $status); 159 160 if($status > 0 ) { 161 print STDERR "**** NOT JPEG: output_fname \n"; 162 unlink $output_fname; 163 } 164 else { 165 my $command = "\"".&util::get_perl_exec()."\" -S gs-magick.pl identify \"$output_fname\" 2>&1"; 166 my $result = `$command`; 167 168 my $type = 'unknown'; 169 my $width = 'unknown'; 170 my $height = 'unknown'; 171 172 my $image_safe = quotemeta $output_fname; 173 if ($result =~ /^$image_safe (\w+) (\d+)x(\d+)/) { 174 $type = $1; 175 $width = $2; 176 $height = $3; 177 } 178 179 my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl"; 180 181 if (($width ne "unknown") && ($height ne "unknown")) { 182 if (($width>200) || ($height>200)) { 183 `$imagick_cmd convert \"$output_fname\" -resize 200x200 /tmp/x.jpg`; 184 `/bin/mv /tmp/x.jpg \"$output_fname\"`; 185 } 186 } 187 $c++; 170 188 } 171 172 if (($width ne "unknown") && ($height ne "unknown")) {173 if (($width>200) || ($height>200)) {174 `convert \"$output_fname\" -resize 200x200 /tmp/x.jpg`;175 `/bin/mv /tmp/x.jpg \"$output_fname\"`;176 }177 }178 $c++;179 189 } 180 190 -
main/trunk/greenstone2/perllib/plugins/HTMLImagePlugin.pm
r21742 r24600 451 451 my ($filename, $orig_fp, $fn, $ext, $reltext, $relreltext, $crcid, $imgs, 452 452 $thumbfp, $pagetitle, $alttext, $filepath, $aggr); 453 454 my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl"; 455 453 456 $aggr = $self->{'aggressiveness'}; 454 457 $imgs = \%{$self->{'imglist'}}; … … 463 466 ($fn, $ext) = $onlyfn =~ /(.*)\.(.*)/; 464 467 $fn = lc $fn; $ext = lc $ext; 465 ($reltext) = "<tr><td>GifComment</td><td>" . ` identify $filepath -ping -format "%c"` . "</td></tr>\n"468 ($reltext) = "<tr><td>GifComment</td><td>" . `$imagick_cmd identify $filepath -ping -format "%c"` . "</td></tr>\n" 466 469 if ($ext eq "gif"); 467 470 $reltext .= "<tr><td>FilePath</td><td>$orig_fp</td></tr>\n"; … … 469 472 if ($ENV{'GSDLOS'} =~ /^windows$/i) { 470 473 $crcid = "$fn.$ext." . $self->{'next_crcid'}++; 471 } else { ($crcid) = `cksum $filepath` =~ /^(\d+)/; } 474 } else { 475 ($crcid) = `cksum $filepath` =~ /^(\d+)/; 476 } 477 472 478 $thumbfp = "$tndir/tn_$crcid.jpg"; 473 ` convert -flatten -filter Hanning $self->{'convert_params'} -geometry "$self->{'thumb_size'}x$self->{'thumb_size'}>" $filepath $thumbfp` unless -e $thumbfp;479 `$imagick_cmd convert -flatten -filter Hanning $self->{'convert_params'} -geometry "$self->{'thumb_size'}x$self->{'thumb_size'}>" $filepath $thumbfp` unless -e $thumbfp; 474 480 if ( ! (-e $thumbfp) ) { 475 481 print STDERR "HTMLImagePlugin: 'convert' failed. Check ImageMagicK binaries are installed and working correctly\n"; return 0; … … 983 989 # can't modify real filepath var because it 984 990 # then can't be located in the page for tag recognition later 991 my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl"; 985 992 ($width, $height) = 986 ` identify $abspath -ping -format "%wx%h"` =~ /^(\d*)x(\d*)$/m;993 `$imagick_cmd identify $abspath -ping -format "%wx%h"` =~ /^(\d*)x(\d*)$/m; 987 994 if (! ($width && $height)) { 988 995 print STDERR "HTMLImagePlugin: ($abspath) 'identify' failed. Check ImageMagicK binaries are installed and working correctly\n"; next; -
main/trunk/greenstone2/perllib/plugins/ImageConverter.pm
r24346 r24600 32 32 no strict 'refs'; # allow filehandles to be variables and viceversa 33 33 34 use util; 34 35 use gsprintf 'gsprintf'; 35 36 … … 131 132 $no_image_conversion_reason = "win95notsupported"; 132 133 } else { 133 my $result = `identify -help 2>&1`; 134 my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl"; 135 my $result = `$imagick_cmd identify -help 2>&1`; 134 136 my $return_value = $?; 135 136 if ( ($ENV{'GSDLOS'} eq "windows" && $return_value == 256) || $return_value == -1) { # Linux and Windows return different values for "program not found" 137 138 # When testing against non-zero return_value ($?), need to shift by 8 139 # and convert it to its signed value. Linux returns -1 and Windows returns 140 # 256 for "program not found". The signed equivalents are -1 and 1 respectively. 141 $return_value >>= 8; 142 $return_value = (($return_value & 0x80) ? -(0x100 - ($return_value & 0xFF)) : $return_value); 143 144 if ( ($ENV{'GSDLOS'} eq "windows" && $return_value == 1) || $return_value == -1) { # Linux and Windows return different values for "program not found" 137 145 $image_conversion_available = 0; 138 146 $no_image_conversion_reason = "imagemagicknotinstalled"; … … 407 415 408 416 # Generate and run the convert command 409 my $convert_command = " convert -interlace plane -verbose $convert_options \"$source_file_path\" \"$target_file_path\"";417 my $convert_command = "\"".&util::get_perl_exec()."\" -S gs-magick.pl convert -interlace plane -verbose $convert_options \"$source_file_path\" \"$target_file_path\""; 410 418 411 419 my $print_info = { 'message_prefix' => $convert_id, … … 439 447 440 448 # Use the ImageMagick "identify" command to get the file specs 441 my $command = " identify \"$image\" 2>&1";449 my $command = "\"".&util::get_perl_exec()."\" -S gs-magick.pl identify \"$image\" 2>&1"; 442 450 print $outhandle "$command\n" if ($verbosity > 2); 443 451 my $result = ''; -
main/trunk/greenstone2/perllib/plugins/StructuredHTMLPlugin.pm
r21801 r24600 36 36 use HTMLPlugin; 37 37 use ImageConverter; # want the identify method 38 use util; 38 39 39 40 use strict; # every perl program should have this! … … 327 328 my $command = "convert -interlace plane -verbose " 328 329 ."-geometry $newsize \"$img_filename\" \"$resized_filename\""; 330 $command = "\"".&util::get_perl_exec()."\" -S gs-magick.pl $command"; 329 331 #print $outhandle "ImageResize: $command\n" if ($verbosity > 2); 330 332 #my $result = '';
Note:
See TracChangeset
for help on using the changeset viewer.