Ruthlessly compressing large images for the web

18,715

Solution 1

Have a look at http://www.irfanview.com/, is an oldy but a goody.

Have found this is able to do multipass png compression pretty well, and does batch processing way faster than PS.

There is also PNGOUT available here http://advsys.net/ken/utils.htm, which is apparently very good.

Solution 2

It will first depend on what kind of image you are trying to compress. The two basic categories are:

  • Picture
  • Illustration

For pictures (such as photographs), a lossy compression format like JPEG will be best, as it will remove details that aren't easily noticed by human visual perception. This will allow very high compression rates for the quality. The downside is that excessive compression will result in very noticeable compression artifacts.

For illustrations that contain large areas of the same color, using a lossless compression format like PNG or GIF will be the best approach. Although not technically correct, you can think of PNG and GIF will compress repetitions the same color very well, similar to run-length encoding (RLE).

Now, as you've mentioned PNG specifically, I'll go into that discussion from my experience of using PNGs.

First, compressing a PNG further is not a viable option, as it's not possible to compress data that has already been compressed. This is true with any data compression; removing the entropy from the source data (basically, repeating patterns which can be represented in more compact ways) leads to the decrease in the amount of space needed to store the information. PNG already employs methods to efficiently compress images in a lossless fashion.

That said, there is at least one possible way to drop the size of a PNG further: by reducing the number of colors stored in the image. By using "indexed colors" (basically embedding a custom palette in the image itself), you may be able to reduce the size of the file. However, if the image has many colors to begin with (such as having color gradients or a photographic image) then you may not be able to reduce the number of colors used in a image without perceptible loss of quality.

Basically it will come down to some trial-and-error to see if the changes to the image will cause any change in image quailty and file size.


The comment by Paul Fisher reminded me that I also probably wouldn't recommend using GIF either. Paul points out that PNG compresses static line art better than GIF for nearly every situation.

I'd also point out that GIF only supports 8-bit images, so if an image has more than 256 colors, you'll have to reduce the colors used.

Also, Kent Fredric's comment about reducing the color depth has, in some situtations, caused a increase in file size. Although this is speculation, it may be possible that dithering is causing the image to become less compressible (as dithering introduces pixels with different color to simulate a certain other color, kind of like mixing pigment of different color paint to end up with another color) by introducing more entropy into the image.

Solution 3

Heres a point the other posters may not have noticed that I found out experimentally:

On some installations, the default behaviour is to save a full copy of the images colour profile along with the image.

That is, the device calibration map, usually SRGB or something similar, that tells using agents how to best map the colour to real world-colours instead of device independant ones.

This image profile is however quite large, and can make some of the files you would expect to be very small to be very large, for instance, a 1px by 1px image consuming a massive 25kb. Even a pure BMP format ( uncompressed ) can represent 1 pixel in less.

This profile is generally not needed for the web, so, when saving your photoshop images, make sure to export them without this profile, and you'll notice a marked size improvement.

You can strip this data using another tool such as gimp, but it can be a little time consuming if there are many files.

Solution 4

pngcrush can further compress PNG files without any data loss, it applies different combinations of the encoding and compression options to see which one works best.

Solution 5

Smush.It claims to go "beyond the limitations of Photoshop". And it's free and web-based.

Share:
18,715
Verlet64
Author by

Verlet64

I like to make things, such as webOS apps, websites, prose, and delicious pancakes.

Updated on August 02, 2022

Comments

  • Verlet64
    Verlet64 almost 2 years

    I have a very large background image (about 940x940 pixels) and I'm wondering if anyone has tips for compressing a file this large further than Photoshop can handle? The best compression without serious loss of quality from Photoshop is PNG 8 (250 KB); does anyone know of a way to compress an image down further than this (maybe compress a PNG after it's been saved)?

    I don't normally deal with optimizing images this large, so I was hoping someone would have some pointers.