Changeset 18466 for gsdl


Ignore:
Timestamp:
02/05/09 16:32:27 (12 years ago)
Author:
mdewsnip
Message:

Implemented -noscaleup option to prevent scaling screenview images bigger than the originals. By Jeffrey Ke at DL Consulting Ltd.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/ImageConverter.pm

    r18404 r18466  
    156156sub generate_images {
    157157    my $self = shift(@_);
    158 
    159158    my ($filename_full_path, $filename_no_path, $doc_obj, $section) = @_;
    160159
    161160    # check image magick status
    162161    return 0 if $self->{'image_conversion_available'} == 0;
     162
    163163    # check the filenames
    164164    return 0 if ($filename_no_path eq "" || !-f $filename_full_path);
     
    241241    }
    242242    if ($self->{'create_screenview'} eq "true") {
    243     $self->create_screenview($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead);
     243    $self->create_screenview($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead, $image_width, $image_height);
    244244    }
    245245}
     
    252252    my $thumbnailsize = $self->{'thumbnailsize'};
    253253    my $thumbnailtype = $self->correct_mime_type($self->{'thumbnailtype'});
    254    
     254
    255255    # Generate the thumbnail with convert
    256256    my ($result,$thumbnailfile)
     
    282282   
    283283    my $self = shift(@_);
    284     my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead) = @_;
     284    my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead, $image_width, $image_height) = @_;
    285285    $url_to_filehead = $filehead unless defined $url_to_filehead;
    286286
    287     # To do: if the actual image smaller than the screenview size,
    288     # we should use the original !
    289    
    290287    my $screenviewsize = $self->{'screenviewsize'};
    291288    my $screenviewtype = $self->correct_mime_type($self->{'screenviewtype'});
     289
     290    # Scale the image, unless the original image is smaller than the screenview size and -noscaleup is set
     291    my $scale_option = "-geometry $screenviewsize" . "x$screenviewsize";
     292    if ($self->{'noscaleup'} && $image_width < $screenviewsize && $image_height < $screenviewsize)
     293    {
     294    $scale_option = "";
     295    }
    292296   
    293297    # make the screenview image
    294298    my ($result,$screenviewfilename)
    295     = $self->convert($original_file, $screenviewtype, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN");   
     299    = $self->convert($original_file, $screenviewtype, $scale_option, "SCREEN");   
    296300   
    297301    #add the screenview as an associated file ...
     
    352356    # but this is no longer needed, as output filename is now
    353357    # explicitly passed back
    354 
    355358    }
    356359
Note: See TracChangeset for help on using the changeset viewer.