Changeset 16825
- Timestamp:
- 2008-08-15T15:33:36+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/ImageConverter.pm
r16771 r16825 26 26 package ImageConverter; 27 27 28 use PrintInfo; 28 use MediaConverter; 29 29 30 30 31 use strict; … … 34 35 35 36 BEGIN { 36 @ImageConverter::ISA = (' PrintInfo');37 @ImageConverter::ISA = ('MediaConverter'); 37 38 } 38 39 … … 111 112 push(@{$hashArgOptLists->{"OptList"}},$options); 112 113 113 my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists, 1); 114 my $self = new MediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1); 115 114 116 115 117 return bless $self, $class; … … 163 165 return 0 if ($filename_no_path eq "" || !-f $filename_full_path); 164 166 167 if ($self->{'cache_generated_images'}) { 168 $self->init_cache_for_file($filename_full_path); 169 } 170 165 171 my $verbosity = $self->{'verbosity'}; 166 172 my $outhandle = $self->{'outhandle'}; … … 195 201 # $doc_obj->add_utf8_metadata($section, "Image", $utf8_filename_meta); 196 202 197 my $result = $self->convert($filename_full_path, $converttotype, "", "");198 ($filename_full_path) = ($result =~ /=>(.*\.$converttotype)/);203 my ($result,$filename_full_path) 204 = $self->convert($filename_full_path, $converttotype, "", "CONVERTTYPE"); 199 205 200 206 $type = $converttotype; … … 250 256 251 257 # Generate the thumbnail with convert 252 my $result = $self->convert($original_file, $thumbnailtype, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB");253 my ($thumbnailfile) = ($result =~ /=>(.*\.$thumbnailtype)/);258 my ($result,$thumbnailfile) 259 = $self->convert($original_file, $thumbnailtype, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB"); 254 260 255 261 # Add the thumbnail as an associated file ... … … 288 294 289 295 # make the screenview image 290 my $result = $self->convert($original_file, $screenviewtype, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN"); 291 my ($screenviewfilename) = ($result =~ /=>(.*\.$screenviewtype)/); 292 296 my ($result,$screenviewfilename) 297 = $self->convert($original_file, $screenviewtype, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN"); 293 298 294 299 #add the screenview as an associated file ... … … 323 328 my $source_file_path = shift(@_); 324 329 my $target_file_type = shift(@_); 325 my $convert_options = shift(@_) || "";326 my $convert_ type= shift(@_) || "";330 my $convert_options = shift(@_) || ""; 331 my $convert_id = shift(@_) || ""; 327 332 328 333 my $outhandle = $self->{'outhandle'}; 329 334 my $verbosity = $self->{'verbosity'}; 330 335 336 my $source_file_no_path = &File::Basename::basename($source_file_path); 337 331 338 # Determine the full name and path of the output file 332 my $target_file_path = &util::get_tmp_filename($target_file_type); 333 push(@{$self->{'tmp_file_paths'}}, $target_file_path); 339 my $target_file_path; 340 if ($self->{'cache_generated_images'}) { 341 my $cached_image_dir = $self->{'cached_dir'}; 342 my $image_root = $self->{'cached_file_root'}; 343 $image_root .= "_$convert_id" if ($convert_id ne ""); 344 my $image_file = "$image_root.$target_file_type"; 345 $target_file_path = &util::filename_cat($cached_image_dir,$image_file); 346 } 347 else { 348 $target_file_path = &util::get_tmp_filename($target_file_type); 349 push(@{$self->{'tmp_file_paths'}}, $target_file_path); 350 351 # Output filename used to be parsed from result line: 352 # my ($ofilename) = ($result =~ m/=>(.*\.$target_file_type)/); 353 # by the function that called 'convert' 354 # but this is no longer needed, as output filename is now 355 # explicitly passed back 356 357 } 334 358 335 359 # Generate and run the convert command 336 360 my $convert_command = "convert -interlace plane -verbose $convert_options \"$source_file_path\" \"$target_file_path\""; 337 print $outhandle "$convert_type $convert_command\n" if ($verbosity > 2); 338 my $result = `$convert_command 2>&1`; 339 print $outhandle "$convert_type RESULT = $result\n" if ($verbosity > 2); 340 341 return $result; 361 362 my $print_info = { 'message_prefix' => $convert_id, 363 'message' => "Converting image $source_file_no_path to: $convert_id $target_file_type" }; 364 365 my ($regenerated,$result,$had_error) 366 = $self->autorun_general_cmd($convert_command,$target_file_path,$print_info); 367 368 return ($result,$target_file_path); 342 369 } 343 370
Note:
See TracChangeset
for help on using the changeset viewer.