Icns files

Icns files are used on Mac OS X systems to store icons for applications. The icns files end with a .icns extension. An icns file can store multiple icons within itself. The Apple Icon Image format used for the files supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512, and 1024 × 1024 pixels in size. OS X can scale the fixed-size icons to be displayed at any intermediate size.

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.

smcFanControl icns icons

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:

smcFanControl 128x128 smcFanControl 48x48 smcFanControl 32x32
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.

 

TechRabbit ad 300x250 newegg.com

Justdeals Daily Electronics Deals1x1 px

Valid HTML 4.01 Transitional

Created: Saturday November 21, 2015