Skip to content

Instantly share code, notes, and snippets.

@ccnyou
Created September 26, 2018 13:16
Show Gist options
  • Save ccnyou/a3711965a61b0ba883683b774e1611c6 to your computer and use it in GitHub Desktop.
Save ccnyou/a3711965a61b0ba883683b774e1611c6 to your computer and use it in GitHub Desktop.
make iOS app icon
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author ervin
import sys
from PIL import Image
for input_file_name in sys.argv[1:]:
need_1x_image_size = [1024]
need_2x_image_size = [20, 29, 40, 60]
need_3x_image_size = [20, 29, 40, 60]
src_image = Image.open(input_file_name)
for size in need_1x_image_size:
real_size = size * 1
resize_image = src_image.resize((real_size, real_size), Image.ANTIALIAS)
output_file_name = "AppIcon-%[email protected]" % size
resize_image.save(output_file_name, "png")
for size in need_2x_image_size:
real_size = size * 2
resize_image = src_image.resize((real_size, real_size), Image.ANTIALIAS)
output_file_name = "AppIcon-%[email protected]" % size
resize_image.save(output_file_name, "png")
for size in need_3x_image_size:
real_size = size * 3
resize_image = src_image.resize((real_size, real_size), Image.ANTIALIAS)
output_file_name = "AppIcon-%[email protected]" % size
resize_image.save(output_file_name, "png")
print "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment