Tinify or TinyPNG or TinyJPEG is the service I use to automatically compress and resize images uploaded to my micropub media endpoint. It’s a great service with a nice developer API that also offers a free limit of 500 compressions per month and has a pay-what-you-use policy after that (but I won’t upload more than 500 images per month anyway). I use a library written in Go to use the API.
The workflow of image uploads to my media endpoint is as follows: the original image gets renamed to
SHA256sum.fileextension, then uploaded to BunnyCDN’s storage, then the image gets compressed by Tinify using the URL of the uploaded original image and then the compressed image gets uploaded to BunnyCDN as well and the URL of the compressed image gets returned.
The advantage of naming media files to their SHA256 sum is that duplicated files aren’t stored twice. I can upload the same image several times and it will always have the same URL.
Here’s an image from vacations last summer:
Tags: BunnyCDN Micropub Tinify