Re: Shrinking gifs.. .
| From: | Nadim Attari | Date: | Thu, 23 Jun 2005 06:24:04 +0000 |
| Subject: | Re: Shrinking gifs.. . | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39748@lists.php.net to get a copy of this message | ||
Hello, i've got this in the comments:
<START>
emilus at galeria-m dot art dot pl (30-Sep-2004 10:02)
To resize or copy image (gif [with gd>=2.0.28] or png) with transparency.
-Take current transparency color
-create a new image with palette like old one and fill new image with
transparent color
-set transparent color
-copy resized image
$colorTransparent = imagecolortransparent($im);
$im2 = imagecreate($new_w,$new_h);
imagepalettecopy($im2,$im);
imagefill($im2,0,0,$colorTransparent);
imagecolortransparent($im2, $colorTransparent);
imagecopyresized($im2,$im,0,0,0,0,$new_w,$new_h,$imsx,$imsy);
<START>
Thanks Martin for the tips..
Regards,
Nadim Attari
"Martin Norland" a écrit dans le message
> nikos wrote:
> > Thank you Martin
> > I install new gd, reconfigure php and now is running OK.
> >
> > But, it was a mass to realize that shortening gifs results to loss
> > transparency(!).
> [snip]
>
> imagecolortransparent()
>
> That function will set the transparent color in an image (only one per
> image). If you read the description carefully it says that it will
> return the existing one if you don't specify a new color...
>
> so:
> $transparent_color = imagecolortransparent($uploaded_img);
> imagecolortransparent($thumbnail, $transparent_color);
>
> That should get you and Nadim what you're looking for, assuming things
> work as promised (I've never used it myself).
>
> If you need to work with pngs and the likes, imagecolorexactalpha /
> imagecolorclosestalpha - requires GD 2.01 and PHP 4.0.6
> (imagecolorallocatealpha requires PHP 4.3.2 though, oddly enough)
>
> cheers,
> --
> - Martin Norland, Sys Admin / Database / Web Developer, International
> Outreach x3257