Changeset 14951


Ignore:
Timestamp:
2008-02-04T13:18:55+13:00 (14 years ago)
Author:
mdewsnip
Message:

All calls to convert now go through one "convert()" function, in preparation for adding image caching.

File:
1 edited

Legend:

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

    r14950 r14951  
    164164    $self->{'tmp_filename'} = $filename;
    165165
    166     my $command = "convert -interlace plane -verbose \"$originalfilename\" \"$filename\"";
    167     print $outhandle "$command\n" if ($verbosity > 2);
    168     my $result = '';
    169     $result = `$command`;
    170     print $outhandle "RESULT = $result\n" if ($verbosity > 2);
     166    my $result = $self->convert($originalfilename, $filename, "", "");
    171167
    172168    $type = $converttotype;
     
    222218
    223219    # Generate the thumbnail with convert
    224     my $command = "convert -interlace plane -verbose -geometry $thumbnailsize"
    225     . "x$thumbnailsize \"$filename\" \"$thumbnailfile\"";
    226     print $outhandle "THUMBNAIL: $command\n" if ($verbosity > 2);
    227     my $result = '';
    228     $result = `$command 2>&1` ;
    229     print $outhandle "THUMB RESULT: $result\n" if ($verbosity > 2);
     220    my $result = $self->convert($filename, $thumbnailfile, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB");
    230221
    231222    # Add the thumbnail as an associated file ...
     
    257248
    258249    # make the screenview image
    259     my $command = "convert -interlace plane -verbose -geometry $screenviewsize"
    260         . "x$screenviewsize \"$filename\" \"$screenviewfilename\"";
    261     print $outhandle "$command\n" if ($verbosity > 2);
    262     my $result = "";
    263     $result = `$command  2>&1` ;
    264     print $outhandle "$result\n" if ($verbosity > 3);
     250    my $result = $self->convert($filename, $screenviewfilename, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN");
    265251
    266252    # get screenview dimensions, size and type
     
    338324    # Return the specs
    339325    return ($type, $width, $height, $size);
     326}
     327
     328
     329sub convert
     330{
     331    my $self = shift(@_);
     332    my $source_file_path = shift(@_);
     333    my $target_file_path = shift(@_);
     334    my $convert_options = shift(@_) || "";
     335    my $convert_type = shift(@_) || "";
     336
     337    my $outhandle = $self->{'outhandle'};
     338    my $verbosity = $self->{'verbosity'};
     339
     340    my $convert_command = "convert -interlace plane -verbose $convert_options \"$source_file_path\" \"$target_file_path\"";
     341    print $outhandle "$convert_type $convert_command\n" if ($verbosity > 2);
     342    my $result = `$convert_command 2>&1`;
     343    print $outhandle "$convert_type RESULT = $result\n" if ($verbosity > 2);
     344
     345    return $result;
    340346}
    341347
Note: See TracChangeset for help on using the changeset viewer.