Changeset 14953

Show
Ignore:
Timestamp:
04.02.2008 13:54:55 (11 years ago)
Author:
mdewsnip
Message:

Changed convert() function to take a target file type instead of a target file path, in preparation for caching images.

Files:
1 modified

Legend:

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

    r14952 r14953  
    162162    if ($converttotype ne "" && $filename !~ m/$converttotype$/) { 
    163163    $originalfilename = $filename; 
    164     $filename = &util::get_tmp_filename() . ".$converttotype"; 
    165  
    166     my $result = $self->convert($originalfilename, $filename, "", ""); 
     164 
     165    my $result = $self->convert($originalfilename, $converttotype, "", ""); 
     166    ($filename) = ($result =~ /=>(.*\.$converttotype)/); 
    167167 
    168168    $type = $converttotype; 
     
    214214    my $thumbnailtype = $self->{'thumbnailtype'} || 'gif'; 
    215215     
    216     my $thumbnailfile = &util::get_tmp_filename() . ".$thumbnailtype"; 
    217  
    218216    # Generate the thumbnail with convert 
    219     my $result = $self->convert($filename, $thumbnailfile, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB"); 
     217    my $result = $self->convert($filename, $thumbnailtype, "-geometry $thumbnailsize" . "x$thumbnailsize", "THUMB"); 
     218    my ($thumbnailfile) = ($result =~ /=>(.*\.$thumbnailtype)/); 
    220219 
    221220    # Add the thumbnail as an associated file ... 
     
    243242    my $screenviewsize = $self->{'screenviewsize'}; 
    244243    my $screenviewtype = $self->{'screenviewtype'} || 'jpeg'; 
    245     my $screenviewfilename = &util::get_tmp_filename() . ".$screenviewtype"; 
    246244 
    247245    # make the screenview image 
    248     my $result = $self->convert($filename, $screenviewfilename, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN"); 
     246    my $result = $self->convert($filename, $screenviewtype, "-geometry $screenviewsize" . "x$screenviewsize", "SCREEN"); 
     247    my ($screenviewfilename) = ($result =~ /=>(.*\.$screenviewtype)/); 
    249248 
    250249    # get screenview dimensions, size and type 
     
    329328    my $self = shift(@_); 
    330329    my $source_file_path = shift(@_); 
    331     my $target_file_path = shift(@_); 
     330    my $target_file_type = shift(@_); 
    332331    my $convert_options = shift(@_) || ""; 
    333332    my $convert_type = shift(@_) || ""; 
     
    336335    my $verbosity = $self->{'verbosity'}; 
    337336 
     337    # Determine the full name and path of the output file 
     338    my $target_file_path = &util::get_tmp_filename() . "." . $target_file_type; 
     339    push(@{$self->{'tmp_file_paths'}}, $target_file_path); 
     340 
     341    # Generate and run the convert command 
    338342    my $convert_command = "convert -interlace plane -verbose $convert_options \"$source_file_path\" \"$target_file_path\""; 
    339343    print $outhandle "$convert_type $convert_command\n" if ($verbosity > 2); 
    340344    my $result = `$convert_command 2>&1`; 
    341345    print $outhandle "$convert_type RESULT = $result\n" if ($verbosity > 2); 
    342  
    343     push(@{$self->{'tmp_file_paths'}}, $target_file_path); 
    344346 
    345347    return $result;