(none) imager-devel
/ help / lists / applications / search /
 

Re: Resizing .gif Graphics

From: Tony Cook (
14829@xyz.molar.is)
Date: Wed 07 Sep 2005 - 01:07:32 GMT

  • Next message: Greg Krieser: "Re: Resizing .gif Graphics"

    On Tue, Sep 06, 2005 at 05:32:20PM -0700, Greg Krieser wrote:
    > Is it possible to resize .gif files just like .jpg files? I've used .jpg resizing without any trouble, but using the same approach with .gif does not work (no error messages, just no results). Any suggestions?
    >
    > $img=Imager->new();
    > $img->open(file=>'/path_to.gif',type=>'gif') || print "failed: ",$img->{ERRSTR},"\n";
    > $width=$img->getwidth();
    > if ($width > 250) {
    > $scaled=$img->scale(xpixels=>250);
    > $scaled->write(file=>'/path_to_resized.gif',type=>'gif') || print "failed: ",$scaled->{ERRSTR},"\n";
    >
    > Thank You,

    Do you get an empty file, or no file at all?

    Does your installed Imager have GIF configured? To test this run:

      perl -MImager -le 'print for keys %Imager::formats'

    and see if gif is listed.

    I ran the following script:

    #!perl -w
    use strict;
    use Imager;

    my $in = shift;
    my $out = shift
      or die "Usage: $0 input output\n";
    my $img = Imager->new;
    $img->read(file=>$in)
      or die "Cannot read $in: ",$img->errstr,"\n";
    my $scaled = $img->scale(xpixels=>100);
    $scaled->write(file=>$out, type=>'gif')
      or die "Cannot write $out: ",$scaled->errstr,"\n";

    which produced a resized GIF image when I tested it.

    -- 
    Tony
    



  •