Skip to content

Instantly share code, notes, and snippets.

@patrickocoffeyo
Created August 19, 2013 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickocoffeyo/6272281 to your computer and use it in GitHub Desktop.
Save patrickocoffeyo/6272281 to your computer and use it in GitHub Desktop.
Turns an icon into website-ready touch icons.
#!/usr/bin/python
import sys
import optparse
import os
import Image
def main():
p = optparse.OptionParser()
p.add_option('--source', '-s', default='')
p.add_option('--output', '-o', default='touch-icons/')
options, arguments = p.parse_args()
if not os.path.exists(options.output):
os.system('mkdir '+options.output)
image = Image.open(options.source)
ext = 'png'
#apple-touch-icons
sizes = [57,72,57,114,144]
for size in sizes:
sizeStr = str(size)
newImage = image.resize((size, size), Image.ANTIALIAS)
newImage.save(options.output+'apple-touch-icon'+sizeStr+'x'+sizeStr+'-precomposed.png')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment