geekices

Tips for optimizing images

Not that long ago, disk space was an expensive commodity: five gigabytes of space for a website could cost you more than €30 per month. Today, you pay that for a whole year and the double or more of disk space. Some hosts even offer “unlimited” storage for a similar monthly price.

Even though disk space has become cheaper, you might be bound to hit the limit of your hosting provider. In order to delay that, you can (and should!) optimize the images you use. This can be done in several ways, but I’m going to document the ones I use.

First, avoid PNG’s unless you need transparency in the image. The format is open, which is great, but the more color information it has the more disk space it tends to use. You can easily confirm this by saving a photo in PNG and JPEG, and then see how much space they take. Chances are the PNG one will use at least two times more disk space than the JPEG one.

Second, if you use GNU/Linux, *BSD or macOS, leverage the jpegoptim utility. This tool does some neat things, like removing the metadata information (EXIF, XMP, etc) and applying lossless optimizations to help you reduce the file size. With the PNG images, you can use optipng to accomplish the same thing. There are also some websites that let you optimize your images (before uploading them to your website), like compressor.io.

This two simple things allowed me to save more than 5GB of disk space for Espalha Factos the first time it was done. It might not sound a lot, but it was around 4,17% of the total disk space.

Leave a Reply

Your email address will not be published. Required fields are marked *