How to manually create icns files using iconutil?

When I test my application, I get this error:

the application set does not contain an icon in the ICNS format containing both 512x512 and 512x512@2x images.

I use icns badges with Img2icns , and until today it always worked correctly. But now I get this error, and there is no way to make it work. I tried to combine two PNG files ( 512x512 and 1024x1024 ) in Img2icns , but I always get this error. I also tried following the instructions in the Apple OS X Human Interface Guide, but when I try to make icon sets, I get this terminal error:

- bash: syntax error near unexpected token 'newline'

I am not very good with terminal commands, so maybe I'm doing something wrong. I wrote:

 iconutil -c icns </Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset> 

If anyone can help, it will be very appreciated. Thanks, Massey.

+92
xcode cocoa icons macos iconutil
06 Sep '12 at 18:28
source share
18 answers

Issue the following instructions ( link ):

Use iconutil to create icns file manually

The iconutil command-line iconutil converts iconutil folders to high-resolution icns files. (You can find the full documentation for this tool by typing man iconutil in Terminal.) Using this tool also compresses the resulting icns file, so you do not need to perform additional compression.

To convert icon set to icns file

Enter this command in the terminal window:

iconutil -c icns <iconset filename>

where <iconset filename> is the path to the folder containing the set of icons that you want to convert to icns . The output is written in the same place as the iconset file , unless you specify the output file, as shown:

iconutil -c icns -o <icon filename> <iconset filename>

In other words, you need to replace <iconset filename> with the path:

 /Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset 

Since the path contains spaces, you need to use double quotes, for example:

 iconutil -c icns "/Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset" 

This command should work correctly.

+57
Sep 06 '12 at 23:15
source share

Here is a script to convert 1024x1024 png (with the name "Icon1024.png") to the required icns file. Save it in a file named "CreateICNS.src" in the folder where your png file is then located in the terminal "cd" in the same folder and enter "source CreateNNS.src" to call it:

 mkdir MyIcon.iconset sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_16x16@2x.png sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png sips -z 64 64 Icon1024.png --out MyIcon.iconset/icon_32x32@2x.png sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_128x128@2x.png sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_256x256@2x.png sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png cp Icon1024.png MyIcon.iconset/icon_512x512@2x.png iconutil -c icns MyIcon.iconset rm -R MyIcon.iconset 
+239
Dec 20 '13 at 12:24
source share

There is a node command line module that does all the work of converting the PNG file to the iconset directory:

 npm install -g node-icns nicns --in adventure-cat.png --out adventure-cat.icns 
+18
Apr 05 '16 at 3:13
source share

These commands (entered in Terminal) worked for me to convert the old icns file to a new format:

 cd Folder_With_Icns_File iconutil -c iconset Your_Icon_Name.icns rm Your_Icon_Name.icns iconutil -c icns Your_Icon_Name.iconset rm -R Your_Icon_Name.iconset 

Update

The -c option for iconutil is no longer supported. Use --convert :

 cd Folder_With_Icns_File iconutil --convert iconset Your_Icon_Name.icns rm Your_Icon_Name.icns iconutil --convert icns Your_Icon_Name.iconset rm -R Your_Icon_Name.iconset 
+12
Oct 29 '12 at 17:59
source share

Although using all kinds of scripts to convert a high-resolution PNG image to a set of different low-resolution copies may seem convenient (and this is true), we should not forget that this type of automatic resizing will lead to noticeably imperfect images.

The lower the resolution, the brighter the icon!

Instead, you should always request a logo in some kind of vector format from your designer, for example, in SVG . With this at hand, you can manually prepare the perfect PNG files in all necessary resolutions, and then create one .icns file that will make your application icon beautiful on every screen, from a mobile phone to some high-quality Retina display. latest iMac.

According to the latest Apple recommendations from 2016, you should prepare the following PNG files:

 +---------------------+--------------------+--------------+ | filename | resolution, pixels | density, PPI | +---------------------+--------------------+--------------+ | icon_16x16.png | 16x16 | 72 | | icon_16x16@2x.png | 32x32 | 144 | | icon_32x32.png | 32x32 | 72 | | icon_32x32@2x.png | 64x64 | 144 | | icon_128x128.png | 128x128 | 72 | | icon_128x128@2x.png | 256x256 | 144 | | icon_256x256.png | 256x256 | 72 | | icon_256x256@2x.png | 512x512 | 144 | | icon_512x512.png | 512x512 | 72 | | icon_512x512@2x.png | 1024x1024 | 144 | +---------------------+--------------------+--------------+ 

After all PNG files are prepared, put them in some directory with the .iconset extension ( Logos.iconset , for example) and execute the following from the terminal:

 iconutil --convert icns Logos.iconset 

If there were no errors after executing this command, then all the files were processed correctly, and you received the Logos.icns file in the same directory containing all the beautiful clear logos for your application that are suitable for any modern screen as of 2017.

+12
Sep 24 '16 at 16:01
source share

An additional comment, when you create the .icns file, you need to rename all pic files with the prefix "icon_", otherwise iconutil will fail with the error message: ".iconset: error: Failed to create ICNS". which is not informative at all.

+8
Jul 30 '15 at 15:08
source share

I refactored the @Henry script so that it looks better:

 #!/bin/zsh NAME=$(basename $1 .png); DIR="$NAME.iconset" mkdir -pv $DIR for mr in 'n' '' '((n+1))' '@2x'; do for n in $(seq 4 9 | grep -v 6); do p=$((2**$m)); q=$((2**$n)) OUT="$DIR/icon_${q}x${q}${r}.png" sips -z $p $p $1 --out $OUT done done iconutil -c icns $DIR rm -frv $DIR 

Update

The -c option for iconutil is no longer supported. Use -—convert :

 #!/bin/zsh NAME=$(basename $1 .png); DIR="$NAME.iconset" mkdir -pv $DIR for mr in 'n' '' '((n+1))' '@2x'; do for n in $(seq 4 9 | grep -v 6); do p=$((2**$m)); q=$((2**$n)) OUT="$DIR/icon_${q}x${q}${r}.png" sips -z $p $p $1 --out $OUT done done iconutil -—convert icns $DIR rm -frv $DIR 
+5
Jun 30 '15 at 23:41
source share

I wrote a bash script to create icns from an SVG file:

 #!/usr/bin/env bash sizes=(16 32 64 128 256 512) largfile='icon_512x512@2x.png' if [ ! -f "$largfile" ]; then convert -background none -resize 1024x1024 "$1" "$largfile" fi for s in "${sizes[@]}"; do echo $s convert -background none -resize ${s}x${s} "$largfile" "icon_${s}x$s.png" done cp 'icon_32x32.png' 'icon_16x16@2x.png' mv 'icon_64x64.png' 'icon_32x32@2x.png' cp 'icon_256x256.png' 'icon_128x128@2x.png' cp 'icon_512x512.png' 'icon_256x256@2x.png' mkdir icon.iconset mv icon_*x*.png icon.iconset iconutil -c icns icon.iconset 

Make sure that imagemagick with librsvg support is installed on the Mac:

 brew install imagemagick --with-librsvg 

This script served me pretty well.




Refresh

For more thorough processing, I created a command line tool (written in Swift) to generate AppIcon.appiconset with the correct layout and format:

https://github.com/kindlychung/genicon

+5
Dec 14 '16 at 16:08
source share

Dead simple.png 👉.icns

  1. Download IconMaker.app - just .applescript won't bite
  2. Drag and drop your .png into the IconMaker.app you just created.

More information : http://eon.codes/blog/2016/12/06/Creating-an-app-icon/

High sierra update iconutil now more strictly refers to the size of the source .png. Read more on this blog post after the jump. ✌️

+4
Dec 06 '16 at 16:12
source share

When I test my application, I get this error:

the application set does not contain an icon in the ICNS format containing both a 512x512 image and a 512x512 @ 2x image.

I am not very good at terminal team, and therefore, maybe I'm doing something wrong. I wrote:

 iconutil -c icns </Users/myname/SDK Mac Apps/MyApp/grafica/icon.iconset> 

First, as I said in a comment on Anna, you probably don't need to use iconutil. You just need to add the icon set to your project and let Xcode convert it for you as part of the assembly.

Anyway this may be your problem:

I tried to put two PNG togheter files (512x512 and 1024x1024) ... but I always get an error.

There is no size 1024 by 1024 points. The 1024 by 1024 pixel element (which was 1024 points before Mountain Lion) is now used for 512 by 512 pixels @ 2x.

Your PNG file should be named accordingly: icon_512x512@2x.png

+3
Sep 07
source share

Apple older than Icon Composer version 2.2 works just fine, you just open .ICNS in it, click the 1024x1024 button and add your image.

+3
Nov 14 '12 at 22:41
source share

Same as @Henry (comment above), but takes the PNG file name as an argument and outputs ICNS with the same name.

NOTE. It is assumed that the PNG file name will have only 1 dot for a separate extension, i.e. xpto.png.

So, save the code below in the box named "CreateICNS.src" in the folder where your png file is located.

THE CODE:

 IFS='.' read -ra ADDR <<< "$1" ICONSET=${ADDR[0]}.iconset mkdir $ICONSET sips -z 16 16 $1 --out $ICONSET/icon_16x16.png sips -z 32 32 $1 --out $ICONSET/icon_16x16@2x.png sips -z 32 32 $1 --out $ICONSET/icon_32x32.png sips -z 64 64 $1 --out $ICONSET/icon_32x32@2x.png sips -z 128 128 $1 --out $ICONSET/icon_128x128.png sips -z 256 256 $1 --out $ICONSET/icon_128x128@2x.png sips -z 256 256 $1 --out $ICONSET/icon_256x256.png sips -z 512 512 $1 --out $ICONSET/icon_256x256@2x.png sips -z 512 512 $1 --out $ICONSET/icon_512x512.png cp $1 $ICONSET/icon_512x512@2x.png iconutil -c icns $ICONSET rm -R $ICONSET 

HOW TO USE :

Then in the terminal "cd" to the same folder and enter:

 source CreateICNS.src {PNG filename} 

where {PNG filename} is the name of your PNG file, that is, xpto.png.

If your file is called abc.png, you will use:

 source CreateICNS.src abc.png 
+3
May 26 '18 at 7:00
source share

@ dardo82 shell code is good and works. Here is simpler in sh (for all * nix) and faster (as it really matters):

 #!/bin/sh # This runs silent, be as verbose as you wish NAME=$(basename ${1} .png) DIR="${NAME}.iconset" mkdir -p ${DIR} for i in 16 32 128 256 512 ; do x="" for p in $i $(($i+$i)) ; do sips -z $p $p ${1} --out "${NAME}.iconset/icon_${i}x${i}${x}.png" x="@2x" done done >/dev/null # /dev/null in lieu of a "-s" silent option iconutil -—convert icns $DIR rm -r $DIR 
+2
Jul 22 '17 at 1:10
source share

Run iconutil -c icns Icon.iconset

Note

  • Icon.iconset is a folder
  • Beginning of a lowercase name icon_
  • When you see Icon.icns with the correct image, you know that it works

enter image description here

+2
Aug 09 '17 at 13:31 on
source share

There are 2 tasks:
- create 10 correct icns files
- get your Xcode project to use them correctly

Since I had hourly problems with both of these tasks, and I also don’t like it when I don’t “see” what is happening, here is the way to be careful:

Create 10 valid icns files:
I used the above script from Henry: it still works for HighSierra and Xcode 9.2, including the "c" command.
The icns file I received in Finder / Quicklook only displayed as one size icon, and in preview mode, only 8 out of 10 sizes.
So I used the terminal, went with cd to my folder and used the command: iconutil -c iconset (icns file name) in the newly created icns file to return the icns file back to the iconset folder, and now, I could see my newly created 10 icon files. Using Quick View of the thumbnail folder (and using full-screen mode to be able to scale them with the slider), I could verify that all sizes actually look very good.

As a digression: they looked better than my attempts to resize in PSE, most likely because I did not find the time to play with all the resizing options in PSE. If you use PSE, make sure your png files are saved without a color profile. In addition, according to my ignorance, for me the 256x256 @ 2 file is the same as the 512x512 file - both at 72dpi. Trying to follow comments with a resolution of 144 dpi did not work for me.

Get your Xcode project to use them correctly:
First, I deleted all my fruitless attempts in Xcode and sent the clean version to the git repository (which would be reasonable, it would be to commit the clean version first - before I frantically started the odyssey of adding icons).
I also made sure that there is no pointer in the info.plist file associated with the "icon file" entry, and that in the general settings of the project, I chose AppIcon for application icons.
Then I added the assets.asset directory and the AppIcon AppIcons and Launch Images folder for the OS to the resources directory.
Then I copied (dragged with the pressed option) from the icon sets folder each png image file into the corresponding AppIcon Spaceholder. So again, I could see what was happening. Xcode really converted this to icns files, or maybe - because my icon folder folder is from the icns folder - the file formats were accepted.

Then archive and confirm, and there will be no errors when downloading or checking.

+1
Feb 23 '18 at 20:11
source share

Hello, for my needs, I made a drop that works with dragging and dropping icons alone or with icons for searching a folder (I limited myself to folders, since searching across volumes of all icons can take a lot of time). Therefore, when dragging and dropping, you can drop folders or applications, everything that may contain an icon. The created icon set bears the name of the original icon, it is placed in the "/ aaaicones" directory and the path to the icon. An example in the folder "/ aaaicones, if you send xcode.app, you will find" /aaaicones/Applications/xcode.app/access.iconset "and / aaaicones / Applications / xcode.app / access.icns (recreated icon) there will be a text file , in which the full path to the icons will be traced, and the path to the corresponding example of the icon set "/Applications/xcode.app/Contents/Applications/Instruments.app/Contents/Frameworks/InstrumentsPlugIn.framework/Versions/A/Resources/access.icns "" /aaaicones/Applications/xcode.app/access.iconset "in the example taken (xcode), this can create a folder at the end (with all the icons and icons) of 214 MB. If you process only one icon, it will placed in the / aaaicone directory s / aIconeseule / "and its source path, example / aaaicones / aIconeseule / Mac Elcapitan / .VolumeIcon.icns and / aaaicones / aIconeseule / Mac Elcapitan / .VolumeIcon.iconset with / aaaicones / aIconeseule / Mac Elcapitan / aalisticones.xt

 on open draggedItems set input to draggedItems set fich to draggedItems set media to {} set theInfo to {} set n to "0" repeat with currentItem in draggedItems set dirchoisi to POSIX path of fich if ".icns" is not in dirchoisi then if "Volumes" is not in dirchoisi then set origi to do shell script "echo /aaaicones" & dirchoisi set fich to do shell script "echo " & fich & " | xxd -p -c 100000 | sed 's#3a#2f#g' | xxd -r -p | sed 's#" & dirchoisi & "#" & "/aaaicones" & dirchoisi & "#g' | xxd -p -c 100000 | sed 's#2f#3a#g' | xxd -r -p" tell application "Finder" if exists (folder fich) then set nn to "0" repeat with nn from 1 to 5 set origi to do shell script "echo " & origi & "/" & " | sed 's#//#" & nn & "/" & "#'" set fich to do shell script "echo " & fich & " | sed 's#:aaaicones*.*#" & origi & "#'" & " | xxd -p -c 100000 | sed 's#2f#3a#g' | xxd -r -p" if not (exists folder (fich as Unicode text)) then try set origi to do shell script "echo " & origi exit repeat end try end if end repeat end if end tell tell application "Finder" if not (exists folder (fich as Unicode text)) then do shell script "mkdir -p -m 0777 " & quoted form of origi end if end tell try set theInfo to do shell script "find " & (quoted form of dirchoisi) & " -name *.icns " end try set AppleScript text item delimiters to return set theList to text items of theInfo set AppleScript text item delimiters to "" set n to count theList repeat with i from 1 to n if "Volumes" is not in item i of theList then set end of media to item i of theList end if end repeat set n to count media set cheminicns to do shell script " > " & quoted form of (origi & "aalisticones.txt") & " | chmod 777 " & quoted form of (origi & "aalisticones.txt") set cheminicns to do shell script "ls " & quoted form of (origi & "aalisticones.txt") tell application "Finder" set letext to (POSIX file cheminicns as alias) set label index of letext to 2 end tell repeat with i from 1 to n set hdd to item i of media try set input to do shell script "echo " & hdd & " | sed 's#//#/#g; s#(#\\(#g;s#)#\\)#g' " do shell script "echo " & quoted form of input & " >>" & quoted form of cheminicns set png to do shell script "echo " & quoted form of input & " | sed 's#.*/##' " do shell script "cp -f " & quoted form of input & " " & quoted form of origi set input to do shell script "iconutil -c iconset " & quoted form of (origi & png) do shell script "echo " & quoted form of (origi & png) & " | sed 's#.icns#.iconset#' >>" & quoted form of cheminicns end try end repeat tell application "Finder" if exists (folder fich) then open fich end if end tell end if else set input to do shell script "echo " & dirchoisi & " | sed 's#//#/#g; s#(#\\(#g;s#)#\\)#g' " set png to do shell script "echo " & quoted form of input & " | sed 's#.*/##' " set origi to do shell script "echo " & quoted form of ("/aaaicones/aIconeseule/" & input) & " | sed 's#/Volumes/##; s#" & quoted form of png & "##'" do shell script "mkdir -p -m 0777 " & quoted form of origi do shell script "echo " & quoted form of input & " >>" & quoted form of origi & "aalisticones.txt" do shell script "cp -f " & quoted form of input & " " & quoted form of origi set input to do shell script "iconutil -c iconset " & quoted form of (origi & png) do shell script "echo " & quoted form of (origi & png) & " >>" & quoted form of origi & "aalisticones.txt" end if end repeat end open 
0
Dec 13 '16 at 10:38
source share

Here's a function, mainly based on Henry's example (may be useful in ~/.bash_profile ):

 mkicns() { if [[ -z "$*" ]] || [[ "${*##*.}" != "png" ]]; then echo "Input file invalid" else filename="${1%.*}" mkdir "$filename".iconset for i in 16 32 128 256 ; do n=$(( i * 2 )) sips -z $i $i "$1" --out "$filename".iconset/icon_${i}x${i}.png sips -z $n $n "$1" --out "$filename".iconset/icon_${i}x${i}@2x.png [[ $n -eq 512 ]] && \ sips -z $n $n "$1" --out "$filename".iconset/icon_${n}x${n}.png (( i++ )) done cp "$1" "$filename".iconset/icon_512x512@2x.png iconutil -c icns "$filename".iconset rm -r "$filename".iconset fi } 

Using

 $ mkicns "filename.png" # double-quote if spaces exist in filename 

Creates 10 sizes from 16x16 to 512x512@2x ; accepts input images in .png .

0
Jun 12 '17 at 22:08
source share

I need it, but for CMake. I also wanted the option of giving him SVG.

Here is the gist: https://gist.github.com/Qix-/f4090181e55ea365633da8c3d0ab5249

And the CMake code:

 # LICENSE: CC0 - go nuts. # Hi :) This is what I used to generate the ICNS for my game, Tide. # Both input formats (SVG vs PNG) work just fine, but in my experience # the SVG came out with noticeably better results (although PNG wasn't # a catastrophe either). The logo for the game was simple enough that # SVG was indeed an option. # To use: # # make_icns( INPUT "path/to/img.{svg,png}" # OUTPUT ICNS_PATH ) # # Then add it as a custom target or use it as a # dependency somewhere - I give you that option. # # For example: # # add_custom_target( my-icns ALL DEPENDS "${ICNS_PATH}" ) # # For the associated utilities: # # - PNG: brew install imagemagick # - SVG: brew cask install inkscape # # Enjoy! function (make_icns_from_png) cmake_parse_arguments ( ARG "" # Boolean args "INPUT;OUTPUT" # List of single-value args "" # Multi-valued args ${ARGN}) find_program ( convert_exe NAMES "convert" "convert.exe" DOC "Path to ImageMagick convert") if (NOT convert_exe) message (FATAL_ERROR "Could not find ImageMagick 'convert' - is ImageMagick installed?") endif () get_filename_component (ARG_INPUT_ABS "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component (ARG_INPUT_ABS_BIN "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") get_filename_component (ARG_INPUT_FN "${ARG_INPUT_ABS_BIN}" NAME_WE) get_filename_component (ARG_INPUT_DIR "${ARG_INPUT_ABS_BIN}" DIRECTORY) set (sourceimg "${ARG_INPUT_ABS}") set (basepath "${ARG_INPUT_DIR}/${ARG_INPUT_FN}") set (output_icns "${basepath}.icns") set (iconset "${basepath}.iconset") set (deplist "") foreach (size IN ITEMS 16 32 128 256 512) math (EXPR size2x "2 * ${size}") set (ipath "${iconset}/icon_${size}x${size}.png") set (ipath2x "${iconset}/icon_${size}x${size}@2x.png") list (APPEND deplist "${ipath}" "${ipath2x}") add_custom_command ( OUTPUT "${ipath}" COMMAND "${convert_exe}" ARGS "${sourceimg}" -resize "${size}x${size}" "${ipath}" MAIN_DEPENDENCY "${sourceimg}" COMMENT "ICNS resize: ${ipath}" VERBATIM) add_custom_command ( OUTPUT "${ipath2x}" COMMAND "${convert_exe}" ARGS "${sourceimg}" -resize "${size2x}x${size2x}" "${ipath2x}" MAIN_DEPENDENCY "${sourceimg}" COMMENT "ICNS resize: ${ipath2x}" VERBATIM) endforeach () add_custom_command ( OUTPUT "${output_icns}" COMMAND iconutil ARGS --convert icns --output "${output_icns}" "${iconset}" MAIN_DEPENDENCY "${sourceimg}" DEPENDS ${deplist} COMMENT "ICNS: ${output_icns}" VERBATIM) if (ARG_OUTPUT) set ("${ARG_OUTPUT}" "${output_icns}" PARENT_SCOPE) endif () endfunction () function (make_icns_from_svg) cmake_parse_arguments ( ARG "" # Boolean args "INPUT;OUTPUT" # List of single-value args "" # Multi-valued args ${ARGN}) set (CMAKE_FIND_APPBUNDLE NEVER) # otherwise, it'll pick up the app bundle and open a shit ton of windows find_program ( inkscape_exe NAMES "inkscape" "inkscape.exe" DOC "Path to Inkscape" PATHS "/usr/local/bin" "/usr/bin") message (STATUS "Inkscape path: ${inkscape_exe}") if (NOT inkscape_exe) message (FATAL_ERROR "Could not find Inkscape - is it installed?") endif () get_filename_component (ARG_INPUT_ABS "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") get_filename_component (ARG_INPUT_ABS_BIN "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") get_filename_component (ARG_INPUT_FN "${ARG_INPUT_ABS_BIN}" NAME_WE) get_filename_component (ARG_INPUT_DIR "${ARG_INPUT_ABS_BIN}" DIRECTORY) set (sourceimg "${ARG_INPUT_ABS}") set (basepath "${ARG_INPUT_DIR}/${ARG_INPUT_FN}") set (output_icns "${basepath}.icns") set (iconset "${basepath}.iconset") set (deplist "") foreach (size IN ITEMS 16 32 128 256 512) math (EXPR size2x "2 * ${size}") set (ipath "${iconset}/icon_${size}x${size}.png") set (ipath2x "${iconset}/icon_${size}x${size}@2x.png") list (APPEND deplist "${ipath}" "${ipath2x}") add_custom_command ( OUTPUT "${ipath}" COMMAND "${inkscape_exe}" ARGS -z -e "${ipath}" -w ${size} -h ${size} "${sourceimg}" MAIN_DEPENDENCY "${sourceimg}" COMMENT "ICNS resize: ${ipath}" VERBATIM) add_custom_command ( OUTPUT "${ipath2x}" COMMAND "${inkscape_exe}" ARGS -z -e "${ipath2x}" -w ${size2x} -h ${size2x} "${sourceimg}" MAIN_DEPENDENCY "${sourceimg}" COMMENT "ICNS resize: ${ipath2x}" VERBATIM) endforeach () add_custom_command ( OUTPUT "${output_icns}" COMMAND iconutil ARGS --convert icns --output "${output_icns}" "${iconset}" MAIN_DEPENDENCY "${sourceimg}" DEPENDS ${deplist} COMMENT "ICNS: ${output_icns}" VERBATIM) if (ARG_OUTPUT) set ("${ARG_OUTPUT}" "${output_icns}" PARENT_SCOPE) endif () endfunction () function (make_icns) cmake_parse_arguments ( ARG "" # Boolean args "INPUT;OUTPUT" # List of single-value args "" # Multi-valued args ${ARGN}) if (NOT ARG_INPUT) message (FATAL_ERROR "INPUT is required") endif () if (NOT IS_ABSOLUTE "${ARG_INPUT}") get_filename_component (ARG_INPUT "${ARG_INPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") endif () if (NOT EXISTS "${ARG_INPUT}") message (FATAL_ERROR "INPUT does not exist: ${ARG_INPUT}") endif () file (RELATIVE_PATH ARG_INPUT "${CMAKE_CURRENT_SOURCE_DIR}" "${ARG_INPUT}") get_filename_component (ARG_INPUT_EXT "${ARG_INPUT}" EXT) if ("${ARG_INPUT_EXT}" STREQUAL ".png") make_icns_from_png (INPUT "${ARG_INPUT}" OUTPUT child_output) elseif ("${ARG_INPUT_EXT}" STREQUAL ".svg") make_icns_from_svg (INPUT "${ARG_INPUT}" OUTPUT child_output) else () message (FATAL_ERROR "INPUT must refer to a .png or .svg, but a ${ARG_INPUT_EXT} was provided") endif () if (ARG_OUTPUT) set ("${ARG_OUTPUT}" "${child_output}" PARENT_SCOPE) endif () endfunction () 
0
26 . '19 1:07
source share



All Articles