Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Created August 15, 2019 10:05
Show Gist options
  • Save dotherightthing/4599973c67688704133fa383d91b2fe7 to your computer and use it in GitHub Desktop.
Save dotherightthing/4599973c67688704133fa383d91b2fe7 to your computer and use it in GitHub Desktop.
[Lossless JPEG compression] PageSpeed keeps telling me that my images are too big. #performance #images

Lossless JPEG compression

Created: 2017.04.07

EXIF

Many WordPress plugins claim to radically reduce file size, but there is often the catch that the EXIF data is stripped. This would mean that my maps wouldn't work anymore, unless I could store that GPS information somewhere before the optimisation took place.

SmushIt

I had heard of SmushIt before and the fact that Stoyan Stefanov was involved lent it some credibility.

But unfortunately http://imgopt.com/ didn't work for me.

In smush.it is dead, long live smushing, Stoyan says],

Looks like Yahoo! stopped maintaining the image optimization service called smush.it.

This is a nice free program. It has various optimisation tools built in. I tried toggling them on and off, and found that Jpegtran reliably reduced the image size by 10%, while preserving the GPS EXIF information.

There is also an API version, a WordPress Plugin with poor reviews, and a PHP Client, which might integrate better with my WordPress upload-from-anywhere workflow. USD $9/month is competitive with the NZD $10/month for the Sitehost CDN that only works with www.~.

I checked with the developer, and unfortunately,

Sorry, currently there is no such option in the API. Metadata is always removed.

jpegtran works by rearranging the compressed data (DCT coefficients), without ever fully decoding the image. Therefore, its transformations are lossless: there is no image degradation at all, which would not be true if you used djpeg followed by cjpeg to accomplish the same conversion. But by the same token, jpegtran cannot perform lossy operations such as changing the image quality.

Found via a Drupal page:

exiftran is a command line utility to transform digital image jpeg images. It can do lossless rotations like jpegtran, but unlike jpegtran it cares about the EXIF data:

Well, I found that jpegtran also cared about the EXIF data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment