js-png-encoder icon indicating copy to clipboard operation
js-png-encoder copied to clipboard

Poor compression ratio

Open kuckir opened this issue 12 years ago • 3 comments

I am compressing 512x512 pixels image and your library produces 1 MB PNG file. GIMP produces 42 kB PNG file for the same imgae.

I don't know too much about compression in PNG, but are you going to implement any better compression methods? Or do you know a JS library, which already implements them?

kuckir avatar Oct 19 '13 13:10 kuckir

The script does not compress the image data at all. PNG uses deflate algorithm and I just use the store method (inflateStore function), because I wasn't interested in that algorithm.

If you can find a javascript deflate library, you can probably use that to compress the data and replace "compressedScanlines = DEFLATE_METHOD + inflateStore(scanlines)" with the appropriate method value and function call

wheany avatar Oct 19 '13 15:10 wheany

Thanks, I found this library https://github.com/imaya/CanvasTool.PngEncoder - it produces 38 kB PNG for my image, but it takes about 2 seconds to encode :(

kuckir avatar Oct 19 '13 16:10 kuckir

Well JavaScript isn't really known for its blazing speed.

wheany avatar Oct 19 '13 22:10 wheany