TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   GD creates bloated pngs. (http://www.talkphp.com/general/2604-gd-creates-bloated-pngs.html)

johnN 04-08-2008 06:27 PM

GD creates bloated pngs.
 
Basically after using GD to resize and crop images I'm getting massive (and I mean massive) file sizes:

this image: http://www.wastemylunch.com/thumbnai...144752_big.png is 256x80 px and it's 64kb.

This is without compression, with it I get 40kb which is still crazy.

This is all using imagecreatetruecolor

when i use only imagecreate I get small but icky files.

any suggestions?

thanks!


Also, if anyone knows if the pngs could just been transformed (and saved) as gifs that are smaller that would be great.

mortisimus 04-08-2008 07:16 PM

I assume that at the end of the script you use:
PHP Code:

imagepng($img); 

This function has a quality parameter, which is set on a scale of 0-9, so I guess just make this quality lower. If that doesn't work, just generate a jpeg with:
PHP Code:

imagejpeg($var); 

or
PHP Code:

imagegif($var); 

See also: imagepng
imagegif
imagewbmp
imagejpeg

johnN 04-08-2008 07:27 PM

Thanks a load, I was under the assumption you couldn't use imagegif for png images but I was wrong, thats for solving my issue so quickly and simply!

mortisimus 04-08-2008 07:33 PM

No problem!


All times are GMT. The time now is 01:18 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0