Changeset 10402
- Timestamp:
- 2005-08-03T12:38:29+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/pdftoimg.pl
r10358 r10402 60 60 if (!parsargv::parse(\@ARGV, 61 61 'convert_to/.*/^', \$convert_to, 62 )) 63 { 64 print_usage(); 62 )) { 63 print_usage(); 65 64 } 66 65 … … 86 85 exit(1); 87 86 } 88 89 # Check that ImageMagick is installed and available on the path (except for Windows 95/98)90 if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) {91 my $result = `identify 2>&1`;92 if ($? == -1 || $? == 256) { # Linux and Windows return different values for "program not found"93 $self->{'imagemagick_not_installed'} = 1;94 #ImageMagick is not installed, thus the convert utility is not available.95 print STDERR "*** ImageMagick is not installed, the convert utility is not available\n";96 return 1;97 }98 }99 my $cmd = "convert";100 101 87 # don't include path on windows (to avoid having to play about 102 88 # with quoting when GSDLHOME might contain spaces) but assume 103 89 # that the PATH is set up correctly. 104 $cmd = "convert" if ($ENV{'GSDLOS'} =~ /^windows$/); 105 $cmd .= " ".$input_filename." ".$output_filestem."/".$input_basename.".".$convert_to; 106 #$cmd .= " \"$input_filename\" -c quit > \"$output_filestem.text\""; 107 108 print STDERR "*** pdftoImge Command = $cmd\n"; 109 90 $cmd = "convert"; 91 #if ($ENV{'GSDLOS'} =~ /^windows$/); 92 #Convert utility will convert the PDF to GIF Animation 93 if ($convert_to eq "gif") { 94 if ($ENV{'GSDLOS'} =~ /^windows$/){ 95 $cmd .= " ".$input_filename." ".$output_filestem."\\".$input_basename."-%02d.".$convert_to; 96 } else { 97 $cmd .= " ".$input_filename." ".$output_filestem."/".$input_basename."-%02d.".$convert_to; 98 } 99 } else { 100 if ($ENV{'GSDLOS'} =~ /^windows$/){ 101 $cmd .= " ".$input_filename." ".$output_filestem."\\".$input_basename.".".$convert_to; 102 } else { 103 $cmd .= " ".$input_filename." ".$output_filestem."/".$input_basename.".".$convert_to; 104 } 105 } 106 110 107 # system() returns -1 if it can't run, otherwise it's $cmds ret val. 111 108 # note we return 0 if the file is "encrypted" … … 119 116 } else { 120 117 # command execute successfully 121 create_itemfile($output_filestem, $input_basename );118 create_itemfile($output_filestem, $input_basename, $convert_to); 122 119 } 123 120 return 0; … … 126 123 sub create_itemfile 127 124 { 128 my ($output_dir, $convert_basename ) = @_;125 my ($output_dir, $convert_basename, $convert_to) = @_; 129 126 opendir(DIR, $output_dir) || die "can't opendir $output_dir: $!"; 130 127 my $item_file = $output_dir."/".$convert_basename.".item"; … … 139 136 sub page_num { 140 137 my ($dir) = @_; 141 my ($page_num) =($dir =~ m/^.*-(\d+)\.(.*)$/i); 142 return $page_num; 138 my $pagenum = ""; 139 if ($ENV{'GSDLOS'} =~ /^windows$/){ 140 ($pagenum) =($dir =~ m/^.*\.(\d+)$/i); 141 } else { 142 ($pagenum) =($dir =~ m/^.*-(\d+)\.(.*)$/i); 143 } 144 $pagenum = $pagenum || 1; 145 return $pagenum; 143 146 } 144 147 … … 147 150 148 151 foreach my $file (@dir_files){ 149 $file =~ m/^.*-(\d+)\.(.*)$/i; 150 152 if ($ENV{'GSDLOS'} =~ /^windows$/ && $convert_to ne "gif"){ 153 ($page_num) =($file =~ m/^.*\.(\d+)$/i); 154 } else { 155 ($page_num) =($file =~ m/^.*-(\d+)\.(.*)/i); 156 } 151 157 # as the converter will convert the document to image files start from page 0 152 $page_num = $1+1;158 $page_num =$page_num + 1 if defined $page_num; 153 159 $page_num = 1 unless defined $page_num; 154 155 160 if ($file !~ /\.item/i){ 156 161 print FILE " <Page pagenum=\"$page_num\" imgfile=\"$file\" txtfile=\"\"/>\n"; 157 162 } 158 163 } 164 159 165 print FILE "</PagedDocument>\n"; 160 166 closedir DIR; … … 165 171 exit (&main(@ARGV)); 166 172 173 174
Note:
See TracChangeset
for help on using the changeset viewer.