Hello,

I have a simple Perl-fu script that loads a jpeg file, scales it and then save the image in a new file.
At least this is how is should work!  The following error occurs when it attempts to save the file:

file_jpeg_save: procedural database execution failed at ./image_resize.pl line 44 (DIE)

Thank you!
 

I am also including the script:
----------------------------
#!/usr/bin/perl -w

use IO::File;
use File::Find;
use File::Basename;
use Gimp qw( :auto );
use Gimp::Fu;

sub pt_image_scale {
        my ($ImagePath, $newImagePath ) = @_;

        # Create a temporary file to hold the file names of the images to be process.
        $fh = IO::File->new("> /tmp/img.txt") || die "Unable to create a new temporary file: $!";

        find (\&write_files, $ImagePath );

        # Close temp file.
        $fh->close();

        # Read the temp file.
        $input = IO::File->new("< /tmp/img.txt") || die "Unable to open temporary file for reading: $!";

        while( defined( $fullImagePath = $input->getline()))
                {
                chomp ( $fullImagePath );

                $image_name = $fullImagePath;

                # Load image from disk
                $image = file_jpeg_load(RUN_NONINTERACTIVE, "$image_name","$image_name");

                # Resize everything
                gimp_image_scale($image, 100, 100);

                $imageName = basename($fullImagePath);
                $newImageFullPath = "$newImagePath" . "/" . "$imageName";

                # Write the new file

                file_jpeg_save( RUN_NONINTERACTIVE,$image,-1,"$newImageFullPath","$newImageFullPath",1,0,0)
                        or die "Could not save file $newImageFullPath\n";

                gimp_image_delete($image);
                }

        $input->close();
        return 1;
}sub write_files {
        ($name, $path, $suffix) = fileparse( $File::Find::name, '\.jpg','\.jpeg','\.JPG','\.JPEG','\.gif','\.GIF');

        if ( $suffix ne "")
                {
                print $fh "$File::Find::name\n";
                }
}

register
        "pt_image_scale",                         #
        "Sacle a image to the desired size",      #
        "A test script",                          #
        "MB",                                     #
        "PT",                    #
        "03/30/2000",                             #
        "<Toolbox>/Xtns/Perl-Fu/PT/Toolbar",# menu path
        "*",                       # Image types
        [
        [PF_STRING, "path_in","image path in","./OLD"],
        [PF_STRING, "path_out","image path out","./NEW"]
        ],
        \&pt_image_scale;

  exit main();
---------------------------
 
 
 


Mihail Baba
mailto:[EMAIL PROTECTED]
 


Reply via email to