tags:

views:

273

answers:

4

I'm working on a site that involves displaying a ton of product images from a variety of online retailers. Since most of the page weight is in the images, I thought it'd be worth looking into techniques for trimming down the file size a bit more.

The images are already JPEGs. I know PNGs have a lot of extra cruft that can balloon the file size considerably, but I have less experience with JPEGs. So, a couple related questions:

  1. Is it worth further compressing the JPEGs? Seems like further compressing something that's already in a lossy format could lead to more harm (poor quality) than good (saving 10+% on the file size).

  2. Are there other techniques to reducing the filesize? I don't know if the EXIF metadata or other metadata are a part of any of these images, and if cutting those is a substantial improvement.

  3. Any experience / recommendations for using GD or ImageMagick (or something else?) There's also commercial image compression library from a company called Spinwave.

+1  A: 

Do you use thumbnail images? If so, are they saved separately or is the larger image loaded in full and just resized on the webpage? Having separate thumbnails sized as you're displaying them on your pages will save a lot of bandwidth.

You can decrease the quality factor on the JPEGs until you can see it. You'll see an improvement in the file size each time you do this. However, as you suspect, since you already have JPEGs, you may see the checkerboarding artifacts in the images sooner because you're compressing already-compressed images.

GD or IM both work well.

John at CashCommons
A: 
  • There are lossless compresions like .ZIP but they are usually worse and not very usefull for an already compresed format.

  • JPEG can have diferent levels of compression. It's your decision how much quality is just enough. A photo from a digital camera can be compressed un one tenth it's size while perfectly suitable for a website.

  • JPEG is better for photographs. PNG is better for logos and plain colors.

  • ImageMagick should allow you to change sizes of a jpeg from command line or a program lib. See http://www.imagemagick.org/Usage/formats/#jpg

borjab
A: 
  1. To me, qualitylooks good until you start to go below 75-80% quality.
  2. I don't think any metadata (JPEG supports IPTC as well) would much inflate the file size - but it could be worth doing some benchmarks of your own (something to blog about!)
  3. I've been brought into PHP to love GD (I know one of the contributors). Just remmeber to cache images as files. For example:

    $im = imagecreatefromjpeg('file.jpg');

    // Output function

    // 80 = quality

    imagejpeg($im, 'savedfile.jpg', 80);

Code formatting doesn't seem to be working!

Ross
Could be because those are tabs instead of spaces?
SeanJA
A: 

My experience shows that some "product" images are created with color space metadata for accurate color reproduction on print media. This can inflate jpeg file size. I was able to reduce jpeg files with something like 30% in some cases, just by removing EXIF.

Ross