Recently a couple of different but related topics have come up, in multiple contexts: server storage space and network bandwidth. Both of those issues are affected by the number of images we post, but also by the size of the images. (I’m referring here to the file size, not the number of pixels – and those two things may not be as closely related as it might appear.)
This post is an attempt to demonstrate some methods for shrinking image file size (and therefore using less space on the server, and less bandwidth on everyone’s browsers, without reducing the pixel size or the quality of the posted images.
All but one of the tools I use here are free. I’ll provide a list at the end. Some of them (especially in the first step) can easily be replaced with other tools, free or not, as you prefer.
Let’s start off with file formats. Now, the great majority of the images that get posted on this site are JPEGs. There are quite a few PNGs, though, and even a few BMPs. (BMP is, generally speaking, the worst format you can use – it offers absolutely no compression at all, and can easily be replaced with PNG or JPEG for very significant savings. Bottom line: don’t use BMP.)
Here’s a PNG image I picked out of my favorites file. It is, IMO, a really fun image, with lots of beautiful boys having fun in the water 🙂 It’s also a 1.8 megabyte file – better than it would be as a BMP (that would be about 3.5 megabytes for a picture this size), but still with lots of room for improvement.
In fact, there’s some room for improvement even while keeping it as a PNG. Here’s the same image, after applying only completely lossless optimizations with the tool “ImageOptim”. Now it’s down to 1.6 megabytes, and still pixel-for-pixel identical to the original image.
We can do a lot better than that, though. Here’s the same image, converted to JPEG with very high quality settings (1). This file is only about a quarter of a megabyte (253,285 bytes if we’re being exact) – better than a 7 to 1 improvement over the original.
That’s a pretty good, but there’s still room for improvement even over that. If we take the above JPEG and run it through JPEGmini Pro (the only non-free tool I used here), we get this image, at 154,757 bytes – about 8% of the size of the original PNG, and still the same pixel size and visual quality:
If you’d rather not spring for JPEGmini, Google produces a free tool called Guetzli that can do almost as well. Here’s the step 1 JPEG, subsequently processed with Guetzli (2), weighing in at 158,493 bytes – not quite as small as JPEGmini’s result, but still only 8.4% of the original:
If you want to shave off even a little more, here’s the JPEGmini file, then run through ImageOptim. It’s down to 151,510 bytes. Most of that comes from stripping out extra EXIF metadata, though, not from anything done to the actual image. (Might be a good idea if you’re posting your own images here, as it removes things like location data, copyright tags, etc).
Tools used here:
ImageMagick (free, multiple platforms): https://imagemagick.org/. Or, use any photo editor or image viewer that can export JPEGs 🙂
ImageOptim (free, only for Mac) – https://imageoptim.com/. Windows users can get similar results from FileOptimizer (https://sourceforge.net/projects/nikkhokkho/, also free). For Linux users, Trimage (https://trimage.org/, also free.)
JPEGMini Pro (US $59, or US $89 with plugins for Lightroom and Photoshop): https://www.jpegmini.com/, or on the Mac app store. Available for Mac and Windows. Free trial available.
Guetzli (free, multiple platforms) – https://github.com/google/guetzli/releases
(1) PNG to JPEG conversion with ImageMagick, using “mogrify -verbose -format jpg -colorspace sRGB -quality 90”. Note that you can get pretty much the same result from other tools, though – Photoshop can export JPEGs, so can Preview (built into macOS), and so can several different tools (ranging in price from free to Photoshop) on Windows or Linux. Pick your favorite 🙂
(2) Guetzli options: “guetzli –verbose –quality 90 jpeg-step1.jpg jpeg-step2-guetzli.jpg”