These days the web is full of images. It is almost ironic that they were originally going to get left out of the first HTML standard, however they sensibly got put in. Images are probably the most highly used web media. The problem with images is that they have to be compressed so that they can load more quickly and can be used more efficiently. Compression is not only important client side, but it can also by vital server side if you have a limit on space. Here are a list of ways you could compress your image:
1. Changing the size
This probably seems really dumb to most users, but it actually quite obvious and can really help you. If you have an image that only needs to be shown at 100 by 75 on a website don’t leave it at 1024 by 768 – you are wasting bandwidth considerably. Even if you only upload a low-res version you probably also want to keep a high resolution version as well in case you need to update your site for screens with higher resolutions. For image search you may also want to consider having an image between 640 by 480 and 1024 by 768 as these are common screen sizes. If you do use a small image on the website, link to the bigger version as the bigger version will show up better for search engines.
2. Changing compression options
Compression can make really small files. Most image editors will give you options on how you want to compress your image and what quality you want to save it at. Simply lowering the quality allows for smaller files. If your image is very small you could also consider reducing the color depth from 24-bit to 16-bit or 8-bit. If there are few colors in the image, this can be useful.
3. Changing the format
You are living in the dark ages if you think it is sensible to upload a .BMP file to the web. Please don’t. Different formats offer different forms of compression. The three main formats are PNG, JPEG and GIF. GIF works a little bit like algebra in that it remembers the number of pixels of a certain color. In a very simple image format five red pixels may be stored as RRRRR where as GIF would just save 5R. GIF is also very useful for ugly animation. PNG works in a similar, but more complex, way and allows for 32-bit images with transparency. PNG doesn’t allow for animations. JPEG tends to be the king of the image formats and can generate incredibly small files, however you do lose quality significantly more than in other formats. In my experience GIF tends to be best for small graphics, PNG best for larger graphics that need transparency and JPEG for everything else. I have also found that when exporting a photo from Photoshop PNG files tend to be larger than JPEG files. JPEGs are by far best at photos – especially large ones.
4. On the fly at the server
This is a really stupid technique that just came into my head. Some websites use PHP to create thumbnails as PHP can also generate image files as well as normal text files. There is a library that does this. If you really needed to you could upload the file once and then use PHP to request it at different resolutions, though it would probably easier to run the script once to generate the smaller files.
5. Using new technologies
Websites such as JPEGmini allow you to dramatically compress your images (sometimes making them 5x smaller) by changing compression methods to the most efficient one. This can be very useful. Another option would be to use Google’s WebP technology which is a new image format that allows for incredibly small files – you can read about it on their site.
As well as these five there are many other techniques, though the first three (and maybe JPEGmini) are probably your best bets. The best method, though, is to learn what works for different images.