Changeset 24600 for main/trunk/greenstone2/perllib/giget.pm
- Timestamp:
- 2011-09-15T16:31:11+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.