Crushing PNGs in .NET

Updated on Thursday, May 13, 2021

Crushing PNGs in .NET

I'm working on page speed and Google PageSpeed Insights is telling me that my PNGs are just way too large. Sadly .NET does not provide any way to optimize PNG images so there is no easy fix - just unmanaged libraries and command line tools.

I have an allergy to manual processes so I've lashed up some code to automatically find and optimize PNGs in my App_Data folder using PNGCRUSH. I can call CrushAllImages() to fix up everything or CrushImage() when I need to fix up a specific PNG. Code below:

(Related: Long term solar powered time lapse camera using Arduino; Capture DropCam (Nest Cam) frames to Google Drive; Style Transfer for Time Lapse Photography)

(You might also like: Android 11 Gripes; Fix search on enter problem in BlogEngine.NET; Vernal (Spring) Equinox 2019)

(All Code Posts)

Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

I Thought He Came With You is Robert Ellison's blog.

Newsletter

Related

Solar powered 5MP Arduino time lapse camera