Re: GD2 gif resizing problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Nichel wrote:
Al wrote:
Philip Hallstrom wrote:
I'm trying to resize GIF images and up with very large files

For example:
Original width = 720
New width = 980
Original height = 1008
New height = 1274
Original filesize = 80kb
After resizing = 235kb

Based on the area increase; I'd expect the file size to about double, not be 4x as large.

$src_img = imagecreatefromgif($filename);

$dest_img = imagecreatetruecolor($new_width, $new_height);

imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $new_width, $new_height, $org_width, $org_height);

imagegif($dest_img, $filename);

I tried using imagetruecolortopalette() and it helped a little; but screwed up the image quality.

Can anyone explain or have a solution?

What's the image? If it's photo-like, save it as a PNG or JPEG and you'll get much smaller files. GIF's don't do very well with some images as it can't encode them very efficiently.

I don't remember which way it goes, but a 1x500 gif of a solid color will be much much much larger than a 500x1 gif of a solid color. The latter it can compress by sayign something like "x color for the next 500 columns on this row".

If it were me, I'd try jpeg/png first.

The image is a simple 4 color street map. Out of the image editor, these images are always much smaller than reasonably compressed jpgs or pngs. I need to keep the file size small as many of our users still use dial-up.


If your original is only 4 color, I'm guessing that your new image is 256 colors, giving you the 'out of proportion' filesize.


That was my original thought also. So I tried using imagetruecolortopalette() with limited colors and the colors went goofy at less than about 100. The file size saving wasn't appreciable.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux