How to Convert macOS Icon (.icns) to Image (.png)
A simple command line to convert .icns file to .png
Let’s say you want to write a blog post for a certain macOS app. You write it great, add screenshots here and there to make the tutorial easy to follow. It’s all done, until it’s time to publish. You probably need to make a cover image at the top of your post or for social media thumbnail. To make it relevant, you might need the icon of the app.
Every macOS app has an icon file inside of it. The filetype is Apple Icon Image format with .icns extension. But you can’t use it in your image editing software like Affinity Photo. You need to convert it to a Portable Network Graphics (PNG) first.
Apple already include a command line tool to do that. You can execute it by using following command on Terminal.
Example of .icns to .png Conversion
Let’s see the command in action.
For this example, I use
/Application/ in Finder.
Automator.app, right click on it, and click
Show Package Contents.
You can find the
Automator.icns from following path.
Copy the selected icon file to the
Next, open the
We need to change directory to
After that, enter following command to convert Automator icon file into a PNG image.
And that’s it.
Automator.png file on the Desktop.
Make it simple
You can make the command more simple and easier to remember by writing a bash function. The following snippet is the bash function I use on my macOS.
With the previous bash function, I can easily enter the command like following snippet.
That’s all I can write today. Thanks for reading! Hope this tutorial is helpful for you.