TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-08-2008, 06:27 PM   #1 (permalink)
The Wanderer
 
Join Date: Apr 2008
Posts: 8
Thanks: 2
johnN is on a distinguished road
Default 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.
johnN is offline  
Reply With Quote
Old 04-08-2008, 07:16 PM   #2 (permalink)
The Contributor
 
mortisimus's Avatar
 
Join Date: Sep 2007
Location: London, UK
Posts: 47
Thanks: 4
mortisimus is on a distinguished road
Default

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
mortisimus is offline  
Reply With Quote
The Following User Says Thank You to mortisimus For This Useful Post:
johnN (04-08-2008)
Old 04-08-2008, 07:27 PM   #3 (permalink)
The Wanderer
 
Join Date: Apr 2008
Posts: 8
Thanks: 2
johnN is on a distinguished road
Default

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!
johnN is offline  
Reply With Quote
Old 04-08-2008, 07:33 PM   #4 (permalink)
The Contributor
 
mortisimus's Avatar
 
Join Date: Sep 2007
Location: London, UK
Posts: 47
Thanks: 4
mortisimus is on a distinguished road
Default

No problem!
mortisimus is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:44 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design