forked from aysiu/Mac-Scripts-and-Profiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateUniversalAppIcons.py
32 lines (23 loc) · 1.21 KB
/
CreateUniversalAppIcons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import os
from shutil import copyfile
import subprocess
# Name of original image (place in the same folder as this script)
originalImage="originalimage.png"
# Main function
def main():
if os.path.isfile(originalImage):
# Define sizes and names based on https://developer.apple.com/library/content/qa/qa1686/_index.html
appIcons = {'512': 'iTunesArtwork.png', '1024': 'iTunesArtwork@2x.png', '120': 'Icon-60@2x.png', '180': 'Icon-60@3x.png', '76': 'Icon-76.png', '152': 'Icon-76@2x.png', '40': 'Icon-Small-40.png', '80': 'Icon-Small-40@2x.png', '120': 'Icon-Small-40@3x.png', '29': 'Icon-Small.png', '58': 'Icon-Small@2x.png', '87': 'Icon-Small@2x.png'}
# Loop through sizes and names
for newSize, newName in appIcons.items():
print "Creating %s with size %s x %s" % (newName, newSize, newSize)
# Make a copy of the original image to modify
copyfile(originalImage, newName)
# Resize the new copy
cmd = '/usr/bin/sips -z ' + newSize + ' ' + newSize + ' ' + newName
subprocess.call(cmd, shell=True)
else:
print "%s is not in the same folder as this script" % originalImage
if __name__ == '__main__':
main()