Python生成各种size的AppIcon代码

在IOS开发,需要要生成各种大小ICON图片。美术导图虽然简单,但是效率低。
用脚本裁剪图片快而且不出错。
PY实现指定大小的ICON.

#encoding=utf-8
# -*- coding: utf-8 -*-
import os
import os.path
from PIL import Image
rootdir=os.path.abspath('.')
os.path.join(rootdir,'ios')

#type:输出图片类型(png, gif, jpeg...)

def ResizeImage(filein, fileout, width, height, type):
  img = Image.open(filein)
  out = img.resize((width, height),Image.ANTIALIAS) #resize image with high-quality
  out.save(fileout, type)
a=[1024,512,180,167,152,144,120,114,100,87,80,76,72,60,58,57,50,40,29]
for i in a:
    ResizeImage(rootdir+'/icon.png',rootdir+'/ios/'+str(i)+'.png',i,i,'png')
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容