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

Re: scale a gif and background turns black

From: Tony Cook (
14246@xyz.molar.is)
Date: Tue 28 Jun 2005 - 12:57:48 GMT


You still need to supply transp=>'threshold' to write_multi().

The following worked here:

use strict;
use Imager;

my ($img) = Imager->read_multi(file=>"303411.gif");

my $thumb = $img->scale(xpixels=>100, ypixels => 100, type => 'min');

$thumb->write(file=>'test.gif', transp=>'threshold');

Tony

On Tue, Jun 28, 2005 at 11:17:44AM +0100, Delfim Machado wrote:
> the background stays black... :(
>
> use Imager;
>
> my @imgs = Imager->read_multi(file=>"./303411.gif");
>
> my @thumb_imgs;
> push(@thumb_imgs, $_->scale(xpixels=>100, ypixels => 100, type =>
> 'min')) for @imgs;
>
> Imager->write_multi({file=>'test.gif'}, @thumb_imgs);
>
>
> This is a bit odd, Imager should manage this issue, right?
>
>
>
> On Jun 28, 2005, at 00:30, Tony Cook wrote:
>
> >On Mon, Jun 27, 2005 at 02:07:53PM +0100, Delfim Machado wrote:
> >
> >>-----BEGIN PGP SIGNED MESSAGE-----
> >>Hash: SHA1
> >>
> >>Hi Tony, this is my code
> >>
> >>use strict;
> >>use Imager;
> >>
> >>my $img = Imager->new;
> >>
> >>$img->read(file=>"./303411.gif");
> >>
> >>my $thumb = $img->scale(xpixels=>100, ypixels => 100, type =>
> >>'min');
> >>
> >>$thumb->write(file=>'test.gif', transp=>'threshold');
> >>
> >
> >Ok, I was looking at the wrong side for this problem.
> >
> >You want:
> >
> > my ($img) = Imager->read_multi(file=>...);
> >
> >The loss of transparency with the single image read is historical,
> >from before we had read_multi() and should change.
> >
> >The current GIF reader tries to build a "screen" based on the
> >background color set in the image (usually black) and place each image
> >on that background.
> >
> >Tony
> >
> >
> >
>
> --
> Delfim Machado
>
> ~ "The point of template engines should be to separate your business
> logic from your presentation logic, not separate your PHP code from
> your HTML code." - Brian Lozier
>