Create .icns ad hoc
I want to create .icns
for an app i made, i know how to make icons in png and .ico
but i don't know much about it.
Which size should i create my icons before to convert them? I don't want my icons to look sharpen or blurred.
I tried just converting them but i don't know if it's just a matter of converting png or ico...
Any advice appreciated!
Solution 1:
There's really no point in shoving a low resolution icon into the high resolution icns format. You'll likely need to modify your scaling and make much larger images and then use a tool to assemble the file.
Have a pretty in depth read of the OS X guidelines and the iOS guidelines (which are more complicated, but a shorter read):
- https://developer.apple.com/library/prerelease/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html
- https://developer.apple.com/library/ios/qa/qa1686/_index.html#//apple_ref/doc/uid/DTS40009882
It's quite a bit of detail on high resolution packing - so you'll likely need a few hours or days depending on how long you've been making resources.
In addition to letting Xcode make your icns resource and the iconutil
command line tool, look into tiff2icns
Solution 2:
In addition to @bmike 's answer earlier, here's an AppleScript that automates the process of .icns creation.
set export_folder to choose folder with prompt "Please select export folder."
set isImage to false
repeat while isImage = false
set import_image to choose file with prompt "Please select image to covert."
try
tell application "Image Events"
launch
set test_image to open import_image
if resolution of test_image = {} or resolution of test_image = {0, 0} then
error ["Invalid Image"]
end if
set isImage to true
end tell
on error
tell application "System Events"
display dialog "Error: Selected file is invalid" with title "Error" with icon caution
end tell
end try
end repeat
try
tell application "Finder"
make new folder at export_folder with properties {name:"Icon.iconset"}
end tell
on error
tell application "System Events"
display dialog "Error: Folder \"Icon.iconset\" already exists, will overwrite unless canceled" with title "Error" with icon caution
end tell
end try
set export_folder_path to POSIX path of export_folder
set import_image_path to POSIX path of import_image
set icon_folder_path to POSIX path of export_folder_path & "/Icon.iconset"
do shell script "sips -z 16 16 " & import_image_path & " --out " & icon_folder_path & "/icon_16x16.png"
do shell script "sips -z 32 32 " & import_image_path & " --out " & icon_folder_path & "/[email protected]"
do shell script "sips -z 32 32 " & import_image_path & " --out " & icon_folder_path & "/icon_32x32.png"
do shell script "sips -z 64 64 " & import_image_path & " --out " & icon_folder_path & "/[email protected]"
do shell script "sips -z 128 128 " & import_image_path & " --out " & icon_folder_path & "/icon_128x128.png"
do shell script "sips -z 256 256 " & import_image_path & " --out " & icon_folder_path & "/[email protected]"
do shell script "sips -z 256 256 " & import_image_path & " --out " & icon_folder_path & "/icon_256x256.png"
do shell script "sips -z 512 512 " & import_image_path & " --out " & icon_folder_path & "/[email protected]"
do shell script "sips -z 512 512 " & import_image_path & " --out " & icon_folder_path & "/icon_512x512.png"
do shell script "cp " & import_image_path & " " & icon_folder_path & "/[email protected]"
do shell script "iconutil -c icns " & icon_folder_path & ";"
display notification "ICNS Creator has finished generating an ICNS" with title "ICNS Creator"