You can view the icons stored within a .icns file on an OS X system using
the Preview program found in the Applications directory. Preview
is likely to be the default application on the system for viewing icns files,
so you should be able to just double-click on the file to open it in Preview or
right-click on the file and choose Open With and select Preview.
The following example is from the
smcfancontrol_v2.icns file found in
/Applications/smcFanControl.app/Contents/Resources
, if the
smcFanControl app was installed in the
Applications directory.
Preview will show a list of the icons stored in the icns file in the left pane of the window used for the file. If you click on an icon in the left pane, it will be displayed in the right pane of the window. In this case, there are six icons stored in the icns file, though only four are visible in the above screen shot.
You can extract a particular icon from the file and save it by clicking on it to select it, then clicking on File then selecting Export. For the Export As format, select JPG, PNG, TIFF, etc. for the file format depending on which format you prefer. E.g., the three images below are the 1st, 2nd, 3rd entries in the icns file:
128 x 128 | 48 x 48 | 32 x 32 |
The file
utility on an OS X system identifies an icns file as
"application/octet-stream".
$ file --mime smcfancontrol_v2.icns smcfancontrol_v2.icns: application/octet-stream; charset=binary
The icns file format
has a 4-byte
magic number stored at the beginning of the file which identifies the
file as an icns file. You can view those first four bytes using the
od
utility; use -t x
to display the results
in hexadecimal and -N 4
to display the first 4 bytes.
You will see 736e6369
displayed for the first 4 bytes.
$ od -t x -N 4 smcfancontrol_v2.icns 0000000 736e6369 0000004
You can determine what icns file is used for an application by examing the
Info.plist
file in the Contents
directory for the
application. E.g., for the smcFanControl application, which I placed in the
Applications
directory, I can search for the CFBundleIconFile
key line and then check the string
line immediately after it
to determine the name of the .icns file.
$ grep -A 1 CFBundleIconFile /Applications/smcFanControl.app/Contents/Info.plist <key>CFBundleIconFile</key> <string>smcfancontrol_v2</string>
Since the string
entry in the example above is
smcfancontrol_v2
, I know that the smcfancontrol_v2.icns
file in the Resources
directory beneath the Content
directory contains the icons for the application.
Created: Saturday November 21, 2015