Current time: 10-30-2020, 03:41 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Apache/PHP Image Compression
11-01-2011, 02:58 AM
Post: #3
RE: Apache/PHP Image Compression
Solution from the Yahoo Performance Team Best Practices on how to optimize images:
  • You can check the GIFs and see if they are using a palette size corresponding to the number of colors in the image. Using imagemagick it's easy to check using
    identify -verbose image.gif
    When you see an image useing 4 colors and a 256 color "slots" in the palette, there is room for improvement.
  • Try converting GIFs to PNGs and see if there is a saving. More often than not, there is. Developers often hesitate to use PNGs due to the limited support in browsers, but this is now a thing of the past. The only real problem is alpha-transparency in true color PNGs, but then again, GIFs are not true color and don't support variable transparency either. So anything a GIF can do, a palette PNG (PNG8) can do too (except for animations). This simple imagemagick command results in totally safe-to-use PNGs:
    convert image.gif image.png
    "All we are saying is: Give PiNG a Chance!"
  • Run pngcrush (or any other PNG optimizer tool) on all your PNGs. Example:
    pngcrush image.png -rem alla -reduce -brute result.png
  • Run jpegtran on all your JPEGs. This tool does lossless JPEG operations such as rotation and can also be used to optimize and remove comments and other useless information (such as EXIF information) from your images.
    jpegtran -copy none -optimize -perfect src.jpg dest.jpg

All the tools listed are available as comand line tools so you just have to install these and call them in a PHP script.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Apache/PHP Image Compression - jarrod1937 - 10-24-2011, 11:56 PM
RE: Apache/PHP Image Compression - allogarage - 11-01-2011 02:58 AM
RE: Apache/PHP Image Compression - SpyGrey - 02-05-2012, 03:08 AM
RE: Apache/PHP Image Compression - pmeenan - 02-06-2012, 11:17 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)