atom / atom

:atom: The hackable text editor
https://atom.io
MIT License
60.19k stars 17.4k forks source link

App icons look washed out #13672

Open simurai opened 7 years ago

simurai commented 7 years ago

Prerequisites

Description

Apparently the added zopflipng compression in https://github.com/atom/atom/pull/12916 makes the icon look "washed out".

Steps to Reproduce

  1. Follow this link. You might have to adjust the scroll position to resources/app-icons/stable/png/1024.png.
  2. See if the two version looks different

Expected behavior:

They should look the same.

Actual behavior:

The right icon looks "washed out/faded".

screen shot 2017-01-16 at 9 28 15 am

Reproduces how often:

I can't reproduce it with my setup. This issue is moved over from https://github.com/atom/atom/pull/13634#issuecomment-272922681

Versions

Additional Information

We could revert that PR, but it would be great if more could confirm the issue. Especially on Linux since macOS and Windows use their own icon format.

Initially reported here: https://github.com/atom/atom/pull/13634#issuecomment-272922681

vmdanilov commented 7 years ago

Hi @simurai,

According to the spec, an sRGB chunk can spare an ICC profile http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.Anc-color. This is what the #12916 stripped.

before:

   Reading IHDR chunk.
   Reading IHDR chunk, length = 13.
   Reading sRGB chunk.
   Reading sRGB chunk, length = 1.
   Reading IDAT chunk.
   Reading IDAT chunk, length = 16384.
   …
   Reading IDAT chunk.
   Reading IDAT chunk, length = 3669.
   Reading IEND chunk.
   Reading IEND chunk, length = 0.

after:

   Reading IHDR chunk.
   Reading IHDR chunk, length = 13.
   Reading IDAT chunk.
   Reading IDAT chunk, length = 365579.
   Reading IEND chunk.
   Reading IEND chunk, length = 0.
…
   Recompressing IDAT chunks in .../atom/resources/app-icons/stable/png/1024.png
   Total length of data found in critical chunks            =    365636

Now, some browser including Chrome still treat untagged images as Device RGB (Color LCD), and the visual difference could be even greater on wide-gamut devices. Since Apple has adopted untagged=sRGB across the whole platform, ICNS files contain images tagged as sRGB (previously, Generic RGB). For example, one from Finder.icns in OS X Yosemite / El Capitan.

   Reading IHDR chunk.
   Reading IHDR chunk, length = 13.
   Reading sRGB chunk.
   Reading sRGB chunk, length = 1.
   Reading IDAT chunk.
   Reading IDAT chunk, length = 8192.
   …
   Reading IDAT chunk.
   Reading IDAT chunk, length = 7083.
   Reading IEND chunk.
   Reading IEND chunk, length = 0.

So, for the sake of consistency, the sRGB chunk has to be restored.

As for the optimization, you can also reduce the actual ICO and ICNS files. Total size went down from 6.52MB to 4.35MB saving 33.3% with Optimage (Disclaimer: I'm the author). These are lossy optimizations but in a more controlled way than #13634, i.e. visually lossless. Lossless is also an option. If needed, I can make a proper PR.