PNG Compression: Set Quality Slider 60%, Keep Transparency
Set a PNG to 60 percent quality in the browser and it can come out bigger than the original. Here is the code that explains why.
I benchmarked this exact thing and the result annoyed me. I dropped a 200KB transparent PNG into a browser-based compressor, slid quality to 60, and the output landed near 70KB — sometimes. On a different image, same slider, same tool, the file came out 210KB, slightly larger than what I fed in. The slider did not lie, exactly. It just was not doing what the label promised on PNG.
The reason is in four lines of the tool's own source, and once you see it you will never trust a "quality" percentage on a PNG the same way again. The short version: a browser canvas only honors the quality argument for lossy formats. PNG is not one of them.
The four lines that decide whether your slider matters at all
This is the compression core, lifted straight from the page's JavaScript:
var mime = webpOn() ? "image/webp" : (item.file.type || "image/jpeg");
if (mime.indexOf("jpeg") === -1 && mime.indexOf("jpg") === -1
&& mime !== "image/webp"
&& item.file.type === "image/png") mime = "image/png";
var q = quality() / 100;
var blob = await canvasToBlob(c, mime, q);
Follow the PNG path through it. You drop in a PNG and you do not toggle WebP. The first line sets mime to the file's own type, so mime is now image/png. The second line is a guard that keeps PNG as PNG rather than letting it fall back to JPEG. Good so far. Then the third line computes your slider value as a 0 to 1 fraction and the fourth hands it to canvas.toBlob(canvas, "image/png", 0.6).
That last argument is where the promise breaks. Per the canvas spec, the quality parameter for toBlob and toDataURL "applies only to image formats that support lossy compression." PNG is a lossless format. So the browser encodes your PNG with its normal lossless pipeline and silently ignores the 0.6 entirely. Run the slider from 10 to 100 on a PNG and you get the same file. The number you moved was never read.
So why did my file get smaller at all — or bigger?
Two different effects are mixed together, and separating them is the whole game.
The first is re-encoding. A browser canvas holds RGBA pixel data. When you draw your PNG onto the canvas and ask for a PNG blob back, the browser re-runs PNG compression with its own encoder settings. On a file that was already optimized, that second pass can go either way. A bloated PNG exported from an editor with a huge palette often shrinks simply because the canvas encoder is more efficient. An already-tight PNG can grow, because the canvas re-encoding is not as good as the original optimizer. That is the 200KB to 70KB you saw, and also the 200KB to 210KB. The slider had nothing to do with either.
The second effect is the WebP toggle. If you turn WebP on, the first line flips mime to image/webp, and now the quality argument is honored for real, because WebP supports lossy compression. Drop the slider to 70 with WebP on and you get a genuinely smaller file with the alpha channel preserved. Drop it to 70 with WebP off and you have changed a number that gets thrown away.
| Output format | Slider honored? | What actually changes the size |
|---|---|---|
| PNG (WebP off) | No — ignored | Only the canvas re-encode; slider value is discarded |
| WebP (WebP on) | Yes — real lossy quality | The slider value directly, plus transparency preserved |
| JPEG | Yes — real lossy quality | Slider value, but transparency is destroyed |
Read that middle row twice. If your goal is smaller transparent images, the WebP toggle is the only control on this page that does what the quality slider claims it does.
Does transparency survive? Yes, and here is why PNG is safe
A PNG image stores an alpha channel: 256 possible levels of transparency per pixel, 0 fully clear to 255 fully opaque. Those intermediate values are what make a soft drop shadow fade cleanly and a cutout edge look smooth instead of stair-stepped.
When this tool keeps your file as PNG, the canvas pipeline carries the alpha channel straight through. The lossless encoder preserves every alpha value exactly. Nothing about PNG compression in a canvas touches transparency, whether the slider says 10 or 100. Set the slider to 100 and you still get the same PNG bytes, alpha intact.
The way people actually lose transparency is by picking the wrong output. Toggle WebP off and drop a PNG into a tool that defaults to JPEG output and you get an opaque image with a black or white background where your cutout used to be. The FAQ on this page calls that out, and it is the real failure mode. It has nothing to do with the quality percentage and everything to do with which format the pipeline chose.
The workflow that actually shrinks transparent PNGs
- For the tightest transparent images, switch to WebP. Turn the WebP toggle on. Now the quality slider is live, and 70 to 80 percent typically halves the file while keeping the alpha channel.
- If you must stay on PNG, ignore the quality slider. Set it anywhere, the output is the same. Judge the result purely by the before and after file sizes the tool reports, not by the number you set.
- Watch the size meter, not the slider. The tool shows original and compressed bytes for each image. That delta is the only signal that reflects reality for PNG.
- Never let the format fall to JPEG. If a transparent image comes out with a dark or white block behind it, the pipeline switched formats. Force PNG or WebP and compress again.
- Re-check your PNGs that grew. If a canvas re-encode made a file larger, its original optimizer was already better than the browser. Keep the original for those, and only route the bloated ones through the tool.
A 60 percent slider that does nothing beats a 60 percent slider that quietly ruins your alpha channel
The comfortable framing is "the slider is broken." The accurate framing is that the tool refused to run a lossy pass on a lossless format, and that refusal is the reason your transparency is still perfect. The number is cosmetic for PNG, and the format guard in the source is what protects your cutouts.
So judge the tool by the right metric: for PNG, the quality slider is decoration and the file-size delta is the truth; for WebP, the slider is real and 70 to 80 percent is your sweet spot. Move to WebP when you need smaller transparent files, and treat the PNG slider as the harmless no-op it actually is. Your alpha channel will thank you either way.
Frequently Asked Questions
Does PNG compression affect transparency?
Proper PNG compression tools preserve the alpha channel, meaning your transparency will remain intact even when you adjust the quality slider. However, using outdated or lossy formats like JPEG for compression will completely remove the transparent background. Always ensure you are saving the final output as a PNG file.
How do I compress a PNG without losing transparency?
To compress a PNG without losing transparency, use a dedicated PNG optimization tool that explicitly supports the alpha channel. Simply adjust the quality slider to your desired level, and the tool will reduce the file size while keeping the transparent pixels intact. Modern tools like TinyPNG or ImageOptim are specifically designed to handle this without visual loss.
What is the best quality setting for PNG compression?
The best quality setting for PNG compression typically ranges between 70% and 80% for web design. This range provides an excellent balance between reducing file size and maintaining visual clarity. You can safely adjust the slider within this range without compromising the transparent areas of your image.
Why does my PNG background turn black after compression?
A PNG background turning black after compression usually happens when the image is accidentally converted to a JPEG format, which does not support transparency. To fix this, ensure your compression tool is explicitly set to output PNG files. This will preserve the alpha channel and keep your transparent backgrounds clear.
Does lowering the PNG quality slider remove the alpha channel?
Lowering the PNG quality slider using modern lossy compression techniques reduces the file size by simplifying color data, but it should not remove the alpha channel. The transparency is stored separately from the color information, so adjusting the quality will only affect the visible pixels. Always use a trusted tool to ensure the alpha channel remains untouched.
What is the optimal PNG quality for web design?
For web design, an optimal PNG quality setting is usually around 75% on the compression slider. This setting drastically reduces the page load time by shrinking the file size while keeping the image looking sharp on high-resolution screens. Transparent elements, like logos or UI icons, will remain perfectly clear at this level.
Are lossy PNG compression tools safe for transparent images?
Yes, lossy PNG compression tools are generally safe for transparent images as long as they specifically support the PNG format. These tools apply selective color reduction to decrease file size without altering the transparent background. Always preview the image after adjusting the slider to ensure the transparent edges remain smooth.
How high should I set the PNG quality slider for logos?
For web design logos with transparency, you should set the PNG quality slider to at least 80% to 90%. Logos often contain sharp edges and text that can become blurry if compressed too aggressively. Keeping the slider higher ensures the transparent background stays clean without introducing artifacts around the logo edges.
Can I use WebP instead of PNG to keep transparency at lower file sizes?
Converting your PNGs to the WebP format is an excellent way to achieve smaller file sizes while perfectly preserving transparency. WebP supports alpha channel transparency and offers superior compression compared to PNG. When adjusting the WebP quality slider, you can often drop it to 70% and still get a smaller file with better visual quality than a compressed PNG.
Does compressing a PNG to a smaller size reduce image quality?
Yes, moving the quality slider to a lower setting will reduce the image quality by stripping away excess color data and fine details. However, the human eye rarely notices this drop in quality on web graphics until the slider goes below 50%. The key is to find the lowest setting before the image starts looking pixelated or blurry.