madskristensen / ImageOptimizer

A Visual Studio extension
Other
163 stars 40 forks source link

HiDPI PNGs are damaged #2

Closed ericlaw1979 closed 9 years ago

ericlaw1979 commented 9 years ago

pngout is run with parameters that strip the pHYs chunk that declares the image's resolution. This causes behavioral changes for images at non-default resolutions (e.g. 300dpi "Retina" images).

This is a common bug in image optimizer tools; e.g. https://github.com/google/zopfli/issues/43

madskristensen commented 9 years ago

Do you know how this can be fixed by passing different parameters to pngout? Here are the parameters it uses https://github.com/madskristensen/ImageOptimizer/blob/master/src/Resources/Tools/png.cmd

ericlaw1979 commented 9 years ago

Yes. The /k parameter allows you to specify chunk names to keep. So we need to figure out what the default set is and add the pHYs to that in the comma-delimited list.

madskristensen commented 9 years ago

With or without the /kpHYs parameter I can't repro. It keeps the image DPI intact

ericlaw1979 commented 9 years ago

Very very strange... Looking at the output of the command file:

pngout C:\temp\output.png C:\temp\output.png /s1 /y /v Name Offset Length CRC Required chunk: IHDR 00000010 0000000d b84f2787 Remove chunk: pHYs 00000029 00000009 78a53f76 Remove chunk: tEXt 0000003e 00000019 71c9653c Required chunk: IDAT 00000063 00046648 6ecb33da Required chunk: IEND 000466b7 00000000 ae426082

madskristensen commented 9 years ago

Yep, it was a caching issue on my end. This seems to work great