Search code examples
macoscocoapngicnsiconutil

Retina-ready .icns icon file on 10.5 Leopard (size limit?)


I'm trying to create a retina ready version of my application's icon. The application targets 10.5+. I'm using Uli Kusterer's oldiconutil to post process the .icns file I make from a .iconset using iconutil on 10.8. The problem is that if I include a 1024x1024 icon ("icon_512x512@2x.png"), the icon does not display on 10.5. Finder doesn't display the icon, and when it is opened in Icon Composer on 10.5, it appears to be blank/empty. If I remove this largest size, the icon displays correctly on 10.5. Interestingly, if I substitute a completely different, simpler 1024x1024 image with a much smaller file size (~300K instead of ~1MB), the icon again works fine on 10.5. So it seems that there may be some limit on the file size of the overall .icns file and/or the individual image chunks in a .icns file that when exceeded breaks compatibility with Leopard.

Compressing the 1024x1024 image with TinyPNG was not enough to fix the problem. It did result in a significantly smaller .icns file before running it through oldiconutil, but the final, JPEG2000 compressed output of oldiconutil was still much larger than the variant using a simpler substitute image, presumably because the more complicated image is simply not as compressible.

Has anyone else run into this problem before? Have you found a solution? If I can't figure out a solution, I'll have to just omit a retina ready application icon until I drop support for 10.5.


Solution

  • Using TinyPNG is the right idea but then when you created the .icns file with oldiconutil, it converts them to JP2, which are larger and causing the problem.

    By using a hex editor, you can locate the individual icons and replace specific JP2 versions with the TinyPNG versions. You will also need to edit the file length bytes in the icns header (bytes 5-8) as well as the icon image length bytes (the 4 bytes following the ic## type) for any icons that you swap out.

    I would suggest that you only replace the retina icons (ic10, ic11, ic12, ic13, ic14) as older OS versions might not be able to use the PNG images.

    If you are just over the 1MB size, you could replace just the largest icon to get under the limit. This will leave most of the icons in the more compatible JP2 format with only the 512@2x (ic10) icon in PNG.

    Hope this helps.