Changeset 17329 for gsdl/trunk/bin
- Timestamp:
- 2008-09-18T14:09:27+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/gsConvert.pl
r17195 r17329 294 294 # Attempt coversion to Image 295 295 if ($output_type =~ m/jp?g|gif|png/i) { 296 $success = &pdf _to_img($dirname, $input_filename, $output_filestem, $output_type);296 $success = &pdfps_to_img($dirname, $input_filename, $output_filestem, $output_type); 297 297 if ($success){ 298 298 return "item"; … … 330 330 # Attempt coversion to Image 331 331 if ($output_type =~ m/jp?g|gif|png/i) { 332 $success = &p s_to_img($dirname, $input_filename, $output_filestem, $output_type);332 $success = &pdfps_to_img($dirname, $input_filename, $output_filestem, $output_type); 333 333 if ($success){ 334 334 return "item"; … … 1002 1002 # Convert a pdf file to various types of image with the convert command 1003 1003 1004 sub pdf _to_img {1004 sub pdfps_to_img { 1005 1005 my ($dirname, $input_filename, $output_filestem, $output_type) = @_; 1006 1006 … … 1010 1010 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found" 1011 1011 #ImageMagick is not installed, thus the convert utility is not available. 1012 print STDERR "*** ImageMagick is not installed, the convert utility is not available \n";1012 print STDERR "*** ImageMagick is not installed, the convert utility is not available. Unable to convert PDF/PS to images\n"; 1013 1013 return 0; 1014 1014 } … … 1018 1018 if ($timeout) {$cmd = "ulimit -t $timeout;";} 1019 1019 $output_type =~ s/.*\_(.*)/$1/i; 1020 $cmd .= "perl -S pdftoimg.pl -convert_to $output_type \"$input_filename\" \"$output_filestem\"";1020 $cmd .= "perl -S pdfpstoimg.pl -convert_to $output_type \"$input_filename\" \"$output_filestem\""; 1021 1021 if ($ENV{'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000) { 1022 1022 $cmd .= " > \"$output_filestem.out\" 2> \"$output_filestem.err\""; … … 1045 1045 if (-s "$output_filestem.err") { 1046 1046 open (ERRLOG, "$output_filestem.err") || die "$!"; 1047 print STDERR "pdf toimg error log:\n";1047 print STDERR "pdfpstoimg error log:\n"; 1048 1048 while (<ERRLOG>) { 1049 1049 print STDERR "$_"; … … 1306 1306 1307 1307 1308 # Convert a PS file to various types of image with the convert utility1309 sub ps_to_img {1310 my ($dirname, $input_filename, $output_filestem, $output_type) = @_;1311 1312 # Check that ImageMagick is installed and available on the path (except for Windows 95/98)1313 if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) {1314 my $result = `identify 2>&1`;1315 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found"1316 #ImageMagick is not installed, thus the convert utility is not available.1317 print STDERR "*** ImageMagick is not installed, the convert utility is not available\n";1318 return 0;1319 }1320 }1321 1322 $cmd = "";1323 if ($timeout) {$cmd = "ulimit -t $timeout;";}1324 $output_type =~ s/.*\_(.*)/$1/i;1325 $cmd .= "perl -S pstoimg.pl -convert_to $output_type \"$input_filename\" \"$output_filestem\"";1326 if ($ENV{'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000) {1327 $cmd .= " > \"$output_filestem.out\" 2> \"$output_filestem.err\"";1328 } else {1329 $cmd .= " > \"$output_filestem.err\"";1330 }1331 1332 # don't include path on windows (to avoid having to play about1333 # with quoting when GSDLHOME might contain spaces) but assume1334 # that the PATH is set up correctly1335 $!=0;1336 my $retval=system($cmd);1337 if ($retval!=0)1338 {1339 print STDERR "Error executing pstoimg.pl";1340 if ($!) {print STDERR ": $!";}1341 print STDERR "\n";1342 }1343 1344 #make sure the converter made something1345 #if ($retval !=0) || ! -s "$output_filestem")1346 if ($retval !=0)1347 {1348 &util::rm("$output_filestem.out") if (-e "$output_filestem.out");1349 #print out the converter's std err, if any1350 if (-s "$output_filestem.err") {1351 open (ERRLOG, "$output_filestem.err") || die "$!";1352 print STDERR "pstoimg error log:\n";1353 while (<ERRLOG>) {1354 print STDERR "$_";1355 }1356 close ERRLOG;1357 }1358 #&util::rm("$output_filestem.html") if (-e "$output_filestem.html");1359 if (-e "$output_filestem.err") {1360 if ($faillogfile ne "" && defined(open(FAILLOG,">>$faillogfile")))1361 {1362 open (ERRLOG, "$output_filestem.err");1363 while (<ERRLOG>) {print FAILLOG $_;}1364 close ERRLOG;1365 close FAILLOG;1366 }1367 &util::rm("$output_filestem.err");1368 }1369 return 0;1370 }1371 &util::rm("$output_filestem.err") if (-e "$output_filestem.err");1372 &util::rm("$output_filestem.out") if (-e "$output_filestem.out");1373 return 1;1374 }1375 1376 1308 # Convert any file to HTML with a crude perl implementation of the 1377 1309 # UNIX strings command.
Note:
See TracChangeset
for help on using the changeset viewer.