back

by emptybits·13y ago·view on hn ↗
Interesting but misleading. The author applied a blur filter which allowed the non-lossy PNG format to compress better.

That's not lossy PNG. The information is lost in the blur (or other pre-process) before PNG gets ahold of it.

8 comments
That's as true lossy as JPEG, which first "blindly" applies quantization in pre-processing step before doing RLE and Huffman compression.

From the example you can see it's not a simple blur, it's side-effect of lossy application of PNG filter.

He's finessing png's lossless compression by removing detail from the source image. So it's lossy compression using a lossless file format (just like you can reduce the palette of an image and the dithering algorithm to reduce gif file sizes).
Blur is a low-pass filter, filtering out higher frequencies in the image. It's the exact same steps as you use with compression. The difference is that you're not using additional transforms and their coefficients to mitigate artifacts and/or slightly improve quality.
They are changing the encoder in such a way that the resulting PNG does not decode exactly, but instead approximates the original image. This turns it into a lossy process. It doesn't really matter if this process happens before or after the PNG encoding step (in fact, from how they describe it, it sounds like it it is integrated into the PNG encoding process, not simply a pre-processor); the combined process of any filtering and PNG encoding is lossy, as in it does not preserve all information necessary to produce a bit-identical output.
Isn't that the definition of a lossy format?

I mean, you are right that it's not a feature of PNG, rather a side effect of some clever preprocessing but that's just semantics.

Interesting but misleading. The author applied a blur filter which allowed the non-lossy PNG format to compress better. That's not lossy PNG.

The information is lost in the blur (or other pre-process) before PNG gets ahold of it.

As I understood it, I think that's opposite of what he's saying. He's saying blur helps restore info.

From the description, I understood the information is lost by deliberately omitting certain pixels that PNG rendering will try to restore from adjacent pixel data, and that he did a diagonal blur to influence the adjacent pixels to contribute better data to the missing ones. Blurring spread info into diagonally adjacent pixels improving results of using them to reconstruct missing ones.

// source is invoking three png utils, so didn't dig into what it's really doing, just saying I think the explanation is that reconstructing pixels saves space and reconstruction is improved by letting diagonal neighbors contain more info on reconstructed pixel through blur.

Incorrect. PNG does not do reconstruction, just delta compression. By applying a diagonal blur, he is removing entropy in a way that the lossless compressor is likely to take advantage of.
I didn't say PNG did anything, so I'm neither correct nor incorrect about what PNG does (though on second read compressing is a better word than omitting, though either way the "guessed" pixel is where the information goes missing). I'm disputing parent's claim author said savings was from blur. He didn't. He said:

> PNG has an ability to “guess” pixels based on their top and left neighbors and successful guesses compress to almost nothing. Usually only few pixels match a guess, but latest ImageAlpha's “Blurizer” option manipulates image data to match the guesses, making compression much much more effective.

What he said is correct.
Right, that's the idea.
>That's not lossy PNG.

You'd be surprised.