|
楼主 |
发表于 2019-10-8 14:31
|
显示全部楼层
- from PIL import Image
- import os
- import sys
- imgPath=sys.argv[1]
- exportType=sys.argv[2]
- isVertical=sys.argv[3]
- print ("图片路径imgPath:%s"%imgPath)
- print ("导出类型:%s"%exportType)
- print ("是否竖屏:%s"%isVertical)
- #创建icon方法
- imageDirectory =imgPath
- imageSize = [29,50,57,58,60,72,76,80,87,100,114,120,144,152,167,180,1024]
- def createImage(size):
- im = Image.open(imageDirectory)
- index = imageDirectory.rfind('/')
- newPath=imageDirectory[0:index]
- newPath=newPath+"/"+"icon_%dx%d.png"%(size,size)
- print("导出成功,路径为:%s"%newPath)
- im.resize((size,size), Image.ANTIALIAS).save(newPath)
- def start():
- for size in imageSize:
- createImage(size)
- #创建launchImage方法
- imageLSizeW=[1242,1242,1125,750,640,640,2048,1668,1668,1536,768];
- imageLSizeH=[2688,2208,2436,1334,1136,960,2732,2388,2224,2048,1024];
- def createImageL(sizeW,sizeH,oneImagePath,indexL):
- im = Image.open(oneImagePath)
- index = oneImagePath.rfind('/')
- newPath=oneImagePath[0:index]
- newPath=newPath+"/"+str(indexL)+"_launchImage_%dx%d"%(sizeW,sizeH)+".png"
- print("导出成功,路径为:%s"%newPath)
- im.resize((sizeW,sizeH), Image.ANTIALIAS).save(newPath)
- def startLaunch(oneImagePath,indexL):
- for index in range(len(imageLSizeW)):
- if isVertical=="1":
- createImageL(imageLSizeW[index],imageLSizeH[index],oneImagePath,indexL)
- elif isVertical=="0":
- createImageL(imageLSizeH[index],imageLSizeW[index],oneImagePath,indexL)
- else:
- createImageL(imageLSizeW[index],imageLSizeH[index],oneImagePath,indexL)
- if __name__ == "__main__":
- if exportType == "icon":
- start()
- elif exportType == "launchImage":
- arrImagePath=imgPath.split("+")
- for indexL in range(len(arrImagePath)):
- tmp=arrImagePath[indexL]
- startLaunch(tmp,indexL)
复制代码 |
|