Changeset 26866 for main/trunk
- Timestamp:
- 2013-02-11T15:15:38+13:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/ImageConverter.pm
r25787 r26866 94 94 'deft' => "100", 95 95 'range' => "1,", 96 'reqd' => "no" } 96 'reqd' => "no" }, 97 98 { 'name' => "apply_aspectpad", 99 'desc' => "{ImageConverter.apply_aspectpad}", 100 'type' => "enum", 101 'list' => [{'name' => "true", 'desc' => "{common.true}"}, 102 {'name' => "false", 'desc' => "{common.false}"}], 103 'deft' => "false", 104 'reqd' => "no" }, 105 { 'name' => "aspectpad_ratio", 106 'desc' => "{ImageConverter.aspectpad_ratio}", 107 'type' => "string", 108 'deft' => "2", 109 'range' => "1,", 110 'reqd' => "no" }, 111 { 'name' => "aspectpad_mode", 112 'desc' => "{ImageConverter.aspectpad_mode}", 113 'type' => "enum", 114 'list' => [{'name' => "al", 'desc' => "{aspectpad.al}"}, 115 {'name' => "ap", 'desc' => "{aspectpad.ap}"}, 116 {'name' => "l", 'desc' => "{aspectpad.l}"}, 117 {'name' => "p", 'desc' => "{aspectpad.p}"}], 118 'deft' => "al", 119 'reqd' => "no" }, 120 { 'name' => "aspectpad_colour", 121 'desc' => "{ImageConverter.aspectpad_colour}", 122 'type' => "string", 123 'deft' => "transparent", 124 'reqd' => "no" }, 125 { 'name' => "aspectpad_tolerance", 126 'desc' => "{ImageConverter.aspectpad_tolerance}", 127 'type' => "string", 128 'deft' => "0.0", 129 'range' => "0,", 130 'reqd' => "no" }, 131 132 97 133 ]; 98 134 … … 213 249 my $url_to_filehead = &unicode::filename_to_url($filehead); 214 250 my $url_to_filename_no_path = &unicode::filename_to_url($filename_no_path); 215 251 252 my $type = "unknown"; 253 216 254 # Convert the image to a new type (if required). 217 255 my $converttotype = $self->{'converttotype'}; 218 my $type = "unknown";219 256 220 257 if ($converttotype ne "" && $filename_full_path !~ m/$converttotype$/) { … … 232 269 } 233 270 } 271 272 # Apply aspect padding (if required). 273 my $apply_aspectpad = $self->{'apply_aspectpad'}; 274 275 if ($apply_aspectpad eq "true") { 276 my $aspectpad_ratio = $self->{'aspectpad_ratio'}; 277 my $aspectpad_mode = $self->{'aspectpad_mode'}; 278 my $aspectpad_colour = $self->{'aspectpad_colour'}; 279 my $aspectpad_tolerance = $self->{'aspectpad_tolerance'}; 280 281 ($type) = ($filename_full_path =~ m/\.(.*?)$/); 282 ##$type = lc($type); 283 284 my ($result, $aspectpad_filename_full_path) 285 = $self->aspectpad($filename_full_path, $type, $aspectpad_ratio, $aspectpad_mode, 286 $aspectpad_colour, $aspectpad_tolerance, "", "ASPECTPAD"); 287 288 $filename_full_path = $aspectpad_filename_full_path; 289 290 if ($self->{'store_file_paths'}) { 291 $self->{'orig_file'} = $aspectpad_filename_full_path; 292 } 293 } 294 295 234 296 235 297 # add Image metadata … … 428 490 } 429 491 492 430 493 sub convert_without_result { 431 494 my $self = shift(@_); … … 439 502 $convert_options,$convert_id,"without_result"); 440 503 } 504 505 506 sub aspectpad { 507 my $self = shift(@_); 508 my $source_file_path = shift(@_); 509 my $target_file_type = shift(@_); 510 my $aspectpad_ratio = shift(@_); 511 my $aspectpad_mode = shift(@_); 512 my $aspectpad_colour = shift(@_); 513 my $aspectpad_tolerance = shift(@_); 514 515 my $aspectpad_options = shift(@_) || ""; 516 my $aspectpad_id = shift(@_) || ""; 517 my $cache_mode = shift(@_) || ""; 518 519 my $outhandle = $self->{'outhandle'}; 520 my $verbosity = $self->{'verbosity'}; 521 522 my $source_file_no_path = &File::Basename::basename($source_file_path); 523 524 # Determine the full name and path of the output file 525 my $target_file_path; 526 if ($self->{'enable_cache'}) { 527 my $cached_image_dir = $self->{'cached_dir'}; 528 my $image_root = $self->{'cached_file_root'}; 529 $image_root .= "_$aspectpad_id" if ($aspectpad_id ne ""); 530 my $image_file = "$image_root.$target_file_type"; 531 $target_file_path = &util::filename_cat($cached_image_dir,$image_file); 532 } 533 else { 534 $target_file_path = &util::get_tmp_filename($target_file_type); 535 push(@{$self->{'tmp_file_paths'}}, $target_file_path); 536 } 537 538 # Generate and run the aspectpad command 539 my $aspectpad_command = "\"".&util::get_perl_exec()."\" -S gs-magick.pl --verbosity=".$self->{'verbosity'}." aspectpad.sh -a $aspectpad_ratio -m $aspectpad_mode -p \"$aspectpad_colour\" -t $aspectpad_tolerance $aspectpad_options \"$source_file_path\" \"$target_file_path\""; 540 541 my $print_info = { 'message_prefix' => $aspectpad_id, 542 'message' => "Aspect padding image $source_file_no_path to: $aspectpad_id $target_file_type" }; 543 $print_info->{'cache_mode'} = $cache_mode if ($cache_mode ne ""); 544 545 my ($regenerated,$result,$had_error) 546 = $self->autorun_general_cmd($aspectpad_command,$source_file_path,$target_file_path,$print_info); 547 548 return ($result,$target_file_path); 549 } 550 551 552 441 553 442 554
Note:
See TracChangeset
for help on using the changeset viewer.