Changeset 14960


Ignore:
Timestamp:
2008-02-12T15:16:08+13:00 (16 years ago)
Author:
davidb
Message:

Conflict between new $self->convert method and controlling whether or not thumbnails are generated resolved

File:
1 edited

Legend:

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

    r14954 r14960  
    4949    'type' => "flag",
    5050    'reqd' => "no" },
     51      { 'name' => "nothumbnail",
     52    'desc' => "{ImagePlug.generatethumbnail}",
     53    'type' => "flag",
     54    'reqd' => "no" },
    5155      { 'name' => "thumbnailsize",
    5256    'desc' => "{ImagePlug.thumbnailsize}",
     
    5963    'type' => "string",
    6064    'deft' => "gif",
     65    'reqd' => "no" },
     66      { 'name' => "noscreenview",
     67    'desc' => "{ImagePlug.generatescreenview}",
     68    'type' => "flag",
    6169    'reqd' => "no" },
    6270      { 'name' => "screenviewsize",
     
    185193    # Also want to set filename as 'Source' metadata to be
    186194    # consistent with other plugins
    187     $doc_obj->add_metadata ($section, "Source", $url);
     195    $doc_obj->add_metadata ($section, "Source", $self->filename_to_metadata($url));
    188196
    189197    my ($image_type, $image_width, $image_height, $image_size)
     
    214222
    215223
    216     # Make the thumbnail image
    217     my $thumbnailsize = $self->{'thumbnailsize'} || 100;
    218     my $thumbnailtype = $self->{'thumbnailtype'} || 'gif';
     224    if (!$self->{'nothumbnail'}) {
     225
     226    # Make the thumbnail image
     227    my $thumbnailsize = $self->{'thumbnailsize'} || 100;
     228    my $thumbnailtype = $self->{'thumbnailtype'} || 'gif';
     229
     230    # Generate the thumbnail with convert
     231    my $result = $self->convert($filename, $thumbnailtype, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB");
     232    my ($thumbnailfile) = ($result =~ /=>(.*\.$thumbnailtype)/);
    219233   
    220     # Generate the thumbnail with convert
    221     my $result = $self->convert($filename, $thumbnailtype, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB");
    222     my ($thumbnailfile) = ($result =~ /=>(.*\.$thumbnailtype)/);
    223 
    224     # Add the thumbnail as an associated file ...
    225     if (-e "$thumbnailfile") {
    226     $doc_obj->associate_file("$thumbnailfile", "thumbnail.$thumbnailtype",
    227                  "image/$thumbnailtype",$section);
    228     $doc_obj->add_metadata ($section, "ThumbType", $thumbnailtype);
    229     $doc_obj->add_metadata ($section, "Thumb", "thumbnail.$thumbnailtype");
    230 
    231     $doc_obj->add_metadata ($section, "thumbicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[Thumb]\" width=[ThumbWidth] height=[ThumbHeight]>");
    232     }
    233 
    234     # Extract Thumnail metadata from convert output
    235     if ($result =~ m/[0-9]+x[0-9]+=>([0-9]+)x([0-9]+)/) {
    236     $doc_obj->add_metadata ($section, "ThumbWidth", $1);
    237     $doc_obj->add_metadata ($section, "ThumbHeight", $2);
    238     }
     234    # Add the thumbnail as an associated file ...
     235    if (-e "$thumbnailfile") {
     236        $doc_obj->associate_file("$thumbnailfile", "thumbnail.$thumbnailtype",
     237                     "image/$thumbnailtype",$section);
     238        $doc_obj->add_metadata ($section, "ThumbType", $thumbnailtype);
     239        $doc_obj->add_metadata ($section, "Thumb", "thumbnail.$thumbnailtype");
     240       
     241        $doc_obj->add_metadata ($section, "thumbicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/[assocfilepath]/[Thumb]\" width=[ThumbWidth] height=[ThumbHeight]>");
     242    }
     243
     244    # Extract Thumnail metadata from convert output
     245    if ($result =~ m/[0-9]+x[0-9]+=>([0-9]+)x([0-9]+)/) {
     246        $doc_obj->add_metadata ($section, "ThumbWidth", $1);
     247        $doc_obj->add_metadata ($section, "ThumbHeight", $2);
     248    }
     249
     250    }
     251
    239252
    240253    # Make a screen-sized version of the picture if requested
    241     if ($self->{'screenviewsize'}) {
     254    if (!$self->{'noscreenview'}) {
    242255
    243256    # To do: if the actual image smaller than the screenview size,
Note: See TracChangeset for help on using the changeset viewer.