DEV Community

Takuya Matsuyama
Takuya Matsuyama

Posted on

How to create .icns file from PNG files on CLI

I had to make another .icns file in order for my app to match the icon style on macOS Big Sur. Here is how to make .icns file from png files. You don't need to use any app for doing it but only a built-in command-line tool.

Make a folder named ***.iconset (e.g., desktop-icon.iconset) and prepare files like so:

> ll
total 49976
drwxr-xr-x  13 user  staff       416 Jan 12 19:23 desktop-icon.iconset/

> ll desktop-icon.iconset/
total 1376
-rw-------  1 user  staff   10416 May  6  2019 icon_128x128.png
-rw-------  1 user  staff   26457 May  6  2019 icon_128x128@2x.png
-rw-------  1 user  staff     665 May  6  2019 icon_16x16.png
-rw-------  1 user  staff    1651 May  6  2019 icon_16x16@2x.png
-rw-------  1 user  staff   26457 May  6  2019 icon_256x256.png
-rw-r--r--@ 1 user  staff   91117 Jan 12 19:06 icon_256x256@2x.png
-rw-------  1 user  staff    1651 May  6  2019 icon_32x32.png
-rw-------  1 user  staff    4331 May  6  2019 icon_32x32@2x.png
-rw-r--r--@ 1 user  staff   91117 Jan 12 19:06 icon_512x512.png
-rw-r--r--@ 1 user  staff  422658 Jan 12 19:21 icon_512x512@2x.png
Enter fullscreen mode Exit fullscreen mode

The folder content looks like this:

Screen Shot 2021-01-12 at 22.31.38

Generate .icns file:

> iconutil --convert icns desktop-icon.iconset
Enter fullscreen mode Exit fullscreen mode

Then, you should get a file like so:

Screen Shot 2021-01-12 at 22.34.20

Hope that helps!


Top comments (1)

Collapse
 
johnmidgley profile image
johnmidgley

Thank you! Worked perfectly!