Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since it's mentioned in the article: Does anyone have experience with lossy png tools?

I'm currently working on a project that needs alpha channels. I've been optimizing the images with pngcrush, which helped (interestingly, images put out with Adobe products where already pretty optimized, but I'm generating thumbnails locally with sips, where pngcrush often saves 60+%).

Still, for photographic images, file size often remains multiple times larger than what I'd expect from a high-quality JPEG.



>Does anyone have experience with lossy png tools?

I do. Lossy PNGs work great for images with not a lot of colors. I use pngquant and optipng a lot in my work to compress a lot of PNG images with practically no visual quality loss.

For very colorful images, lossy (quantized & dithered) PNGs just don't work, though. They just end up looking nasty with larger filesizes than what high quality JPG gives you.


There's also a method for true-color lossy PNGs that blurs instead of dithering: https://speakerdeck.com/pornel/lossy-png-for-true-color-imag... (https://github.com/pornel/mediancut-posterizer). It's not as efficient as PNG8, but still better than nothing :)


I use optipng and pngquant together myself... it's been a while since I've looked though... here's the contents of my "!Drag PNG here to Optimize (pngquant and optipng as png8).bat" file ... should be able to do similar in bash/zsh script.

    @echo off

    set batchdir=%~d0%~p0

    :start
     
    "%batchdir%pngquant.exe" --ext .q.png --force --verbose 256 %1
    "%batchdir%optipng.exe" -force -o4 -out "%~dpn1.opt.png" "%~dpn1.q.png"

    del "%~dpn1.q.png"

    shift
    if NOT x%1==x goto start

    rem pause


Ditto what Diaz said. The author of this article BTW also makes some rad lossy PNG tools. I took a 3MB website down to under 1MB recently, the majority of which were screenshots.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: