Changeset 31926


Ignore:
Timestamp:
09/01/17 12:27:21 (3 years ago)
Author:
kjdon
Message:

added a new option 'store_original_image'. If this is set, and the original image was converted to a new type, then we will also store the original. This was added for pei jones. Have tif images, want png source, thumb and screen images, but also want the tif files for doc editing purposes. have done no work on this if there are funny characters in the filename or different encodings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/ImageConverter.pm

    r31492 r31926  
    9696    'range' => "1,",
    9797    'reqd' => "no" },
    98 
     98    { 'name' => "store_original_image",
     99      'desc' => "{ImageConverter.store_original_image}",
     100      'type' => "flag",
     101      'reqd' => "no"},
    99102      { 'name' => "apply_aspectpad",
    100103    'desc' => "{ImageConverter.apply_aspectpad}",
     
    212215    # The following is potentially very muddled thinking (but currently seems to work)
    213216    # generate_images currently called from ImagePlugin and PagedImagePlugin
    214     my $filename_no_path = $filename_encoded_no_path;
    215 
     217    my $filename_no_path = $filename_encoded_no_path;
     218    my $original_filename_full_path = $filename_full_path;
     219    my $original_filename_no_path = $filename_no_path;
     220    my $original_file_was_converted = 0;
     221   
    216222    # check image magick status
    217223    return 0 if $self->{'image_conversion_available'} == 0;
     
    258264    if ($converttotype ne "" && $filename_full_path !~ m/$converttotype$/) {
    259265#   #    $doc_obj->add_utf8_metadata($section, "Image", $utf8_filename_meta);
    260 
    261266    my ($result, $converted_filename_full_path)
    262267        = $self->convert($filename_full_path, $converttotype, "", "CONVERTTYPE");
     
    269274        $self->{'orig_file'} = $converted_filename_full_path;
    270275    }
     276    $original_file_was_converted = 1;
    271277    }
    272278
     
    292298        $self->{'orig_file'} = $aspectpad_filename_full_path;
    293299    }
    294     }
    295    
    296 
    297 
     300    $original_file_was_converted = 1;
     301
     302    }
     303   
    298304    # add Image metadata
    299305    $doc_obj->add_utf8_metadata($section, "Image", $url_to_filename_no_path); # url to generated image
     
    345351    $doc_obj->associate_file($filename_full_path, $filename_no_path, "image/$type", $section);
    346352
     353    if ($self->{'store_original_image'} && $original_file_was_converted) {
     354    # hack to guess the filetype
     355    my ($orig_type) = ($original_filename_full_path =~ m/\.(.*?)$/);
     356    # add the original image as an associated file
     357    $doc_obj->associate_file($original_filename_full_path, $original_filename_no_path, "image/$orig_type", $section);
     358    }
    347359    if ($self->{'create_thumbnail'} eq "true") {
    348360    $self->create_thumbnail($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead);
Note: See TracChangeset for help on using the changeset viewer.