I am giving TinyPNG a go because Lighthouse is moaning about image sizes on one of my websites. It's an automated image compression service/API/panda that does smart PNG/JPEG compression, and it's free for light usage (<500 images a month).
In literally 3 lines I got it working, which has to be one of the lowest barriers to entry for any utility I've tried. And I'm running my CMS in debug while typing this post and testing it with this stormtrooper pic. (The revolution will be live.)
I've got a method with a byte array in it already (called "blob") that gets converted to a Stream before it's uploaded into blob storage. After exchanging my email address for a developer key and installing the "Tinify" nuget package that code changes to:
Tinify.Key = "yourkeyhereblahblahblahblahblahblah";
var resultData = Tinify.FromBuffer(blob).ToBuffer();
minifiedStream = new MemoryStream(resultData.Result);
The source image was a full res iPhone shot (2.5Mb). Resulting blob that got sent to storage... 937Kb. Which is still huge, but not as huge. I'm assuming further optimisations could be achieved passing params to resize the image, set compression, tweaking the starboard power coupling, etc. Of course, there should also be some async/await shennanigans in there. And error handling. Whatevs.
But TinyPNG? Working image compression in 3 lines of code? Yup.
Officially certified: Nifty.
Now to read the documentation and implement it properly...
Posted Wednesday, February 14, 2018.