How to scale iOS app icon for different sizes

Each time you change the application icon, you must create the correct icon sizes for Xcode. I have always been looking for an effective way to create these icons.

Obviously, the automated process will not care about fitting pixels or similar details. But simple AppleScript should do the trick for most of us.

The next screen displays all the necessary sizes:

enter image description here

I compiled different sources and made a simple working script for everyone to share ... so here you go - just check my answer below.

+4
source share
2 answers

AppleScript ... :

on run
    set f to choose file
    processTheFiles({f})
end run

on open theFiles
    processTheFiles(theFiles)
end open

on processTheFiles(theFiles)
    tell application "Image Events" to launch
    repeat with f in theFiles
        set thisFile to f as text

        -- iPhone       
        scaleAndSave(f, thisFile, 29 * 1, "-iPhone-29")
        scaleAndSave(f, thisFile, 29 * 2, "-iPhone-29@2x")
        scaleAndSave(f, thisFile, 40 * 2, "-iPhone-40@2x")
        scaleAndSave(f, thisFile, 57 * 1, "-iPhone-57")
        scaleAndSave(f, thisFile, 57 * 2, "-iPhone-57@2x")
        scaleAndSave(f, thisFile, 60 * 2, "-iPhone-60@2x")

        -- iPad
        scaleAndSave(f, thisFile, 29 * 1, "-iPad-29")
        scaleAndSave(f, thisFile, 29 * 2, "-iPad-29@2x")
        scaleAndSave(f, thisFile, 40 * 1, "-iPad-40")
        scaleAndSave(f, thisFile, 40 * 2, "-iPad-40@2x")
        scaleAndSave(f, thisFile, 50 * 1, "-iPad-50")
        scaleAndSave(f, thisFile, 50 * 2, "-iPad-50@2x")
        scaleAndSave(f, thisFile, 72 * 1, "-iPad-72")
        scaleAndSave(f, thisFile, 72 * 2, "-iPad-72@2x")
        scaleAndSave(f, thisFile, 76 * 1, "-iPad-76")
        scaleAndSave(f, thisFile, 76 * 2, "-iPad-76@2x")

    end repeat
    tell application "Image Events" to quit
end processTheFiles

on scaleAndSave(aPath, aFile, aSize, aName)
    set savePath to text 1 thru -5 of aFile & aName & text -4 thru -1 of aFile
    tell application "Image Events"
        set a to open aPath
        scale a to size aSize
        save a in savePath
    end tell
    delay 0.2
end scaleAndSave

, ... , , : https://dl.dropboxusercontent.com/u/170740/AppIcon.applescript

, ...

+4

script, script . :

# Generate all icon files from Icon_1024.png

#smaller app store icon
sips --resampleWidth 512 Icon_1024.png --out Icon_512.png

#iphone icons
sips --resampleWidth 114 Icon_1024.png --out Icon\@2x.png
sips --resampleWidth 57 Icon_1024.png --out Icon.png

#ipad icons
sips --resampleWidth 144 Icon_1024.png --out Icon-72\@2x.png
sips --resampleWidth 72 Icon_1024.png --out Icon-72.png
+2

Source: https://habr.com/ru/post/1537685/


All Articles