5

I can make a jpeg from a png:

sips -s format jpeg myIcon.png --out myIcon.jpeg

But the same command won't work on icns:

sips -s format icns myIcon.png --out myIcon.icns
# Error: Unable to write image to file ...myIcon.icns

How can I get around this error?

Kevin Kostlan
  • 3,311
  • 7
  • 29
  • 33

1 Answers1

9

sips can only convert images into .icns if the initial image file is 256x256, 512x512, and as far as I've been able to verify, 1024x1024. You would have to first resize your image to one of these sizes, and then use the format option to convert the image to a .icns. The code below does this.

First, resize the image to one of the resolutions above:

sips -z 256 256 myIcon.png --out myIconResized.png

OR

sips -z 512 512 myIcon.png --out myIconResized.png

OR

sips -z 1024 1024 myIcon.png --out myIconResized.png

Second, convert the resized image file to a .icns file.

sips -s format icns myIconResized.png --out myIcon.icns

Now you have a .icns file from the resized image file.

Community
  • 1
  • 1
colossatr0n
  • 2,215
  • 1
  • 12
  • 18
  • Interesting. Now that retina displays are mainstream, macOS uses 1024*1024 icons, if I'm not wrong. How to create ICNS with those requirements? – Teejay May 15 '19 at 22:31
  • @Teejay I've updated the answer to include 1024x1024 icons. Thanks for bringing that up. Just tested it and it works. – colossatr0n May 19 '19 at 05:22