使用python生成iOS各规格icon

使用python可以很方便的一次导出所需的各种大小icon,省时省力,美术只需要准备一个最大的icon就行了。

#!/usr/bin/python
# -*- coding: utf-8 -*-
from PIL import Image
infile = raw_input('Please enter the image path: ')
outPath = raw_input('Please enter the export path: ')
print('infile:' + infile)
img = Image.open(infile)
(w,h) = img.size
print('originW:' + str(w) + ',originH:' + str(h))

arr = [180,152,144,120,114,100,87,80,76,72,57,58,50,40,29]
for index in arr:
newW = index
newH = h * newW / w
outfile = outPath + '/'+ 'Icon-' + str(index) + '.png'
out = img.resize((newW,newH),Image.ANTIALIAS) #resize image with high-quality
out.save(outfile)
print('output file ' + 'Icon-' + str(index) + '.png...')
print('Export all ICONS finished...')

保存成python文件就行了!

posted @ 2017-07-06 16:26  随风的博客  阅读(184)  评论(0编辑  收藏  举报