How I Fixed a Broken Lossless Image Compression Process

2026-08-02 · 3 min read

Our CI pipeline was deploying 85MB of unoptimized product images to production every release. The CDN cache was thrashing, bandwidth bills were climbing, and nobody noticed because 'images have always been slow.' I added a compression step to the build — 85MB dropped to 12MB. The DevOps team sent me a thank-you card.

When You Actually Need This — And When You Do Not

Not every file needs this conversion. I learned to ask two questions before touching a single file. First: what is the final destination? If it is a modern browser, the native format might work fine — Google's Web Vitals program — Largest Contentful Paint (LCP) thresholds confirms that browser support is broader than most developers assume. Second: does the target platform have a format requirement? Some CMS platforms, email clients, and print workflows demand specific formats and will reject anything else.

I wasted hours early in my career converting files that did not need converting. Now I only reach for our advanced compression engine when the destination actually requires it. The time saved adds up fast when you process hundreds of files a month.

The Workflow I Settled On After Too Many Do-Overs

I used to convert files one at a time, checking each output manually. That worked for ten files. It did not work for two hundred. After one particularly painful project where I had to redo thirty files because I missed a transparency setting, I built a routine that has not failed me since.

The key is doing three things in order: validate the source format against the PNG specification (ISO/IEC 15948:2004) — lossless compression algorithm, pick the right output settings for the destination, then spot-check the first three outputs before batch-processing the rest. Our support page handles the second step automatically — it detects what the destination needs and applies the right settings without me having to remember every format quirk.

One Check I Run Before Calling Any Export Done

Open the output file on a dark background. Just do it. Half the transparency issues I have seen in production were invisible on white backgrounds. The alpha channel looked fine until someone dropped the image onto a dark mode UI, and suddenly there was a white halo around every edge.

This single habit — flipping the background from light to dark — has caught more bad exports than every other check combined. It takes five seconds and has saved me from redoing entire batches. Try it on your next export →

Maria Rodriguez Written by Maria Rodriguez — DevOps Engineer. More about me →