python自動產生iOS各尺寸規格icon

來源:互聯網
上載者:User

標籤:python   ios   icon   

使用python自動產生iOS各尺寸規格icon(基於一張1024大圖),代碼如下:

import PIL.ImageimgNames = [((72,72),"icon-72.png"),((40,40),"icon-40.png"),((80,80),"[email protected]"),((50,50),"icon-50.png"),((100,100),"[email protected]"),((60,60),"icon-60.png"),((120,120),"[email protected]"),((180,180),"[email protected]"),((72,72),"icon-72.png"),((114,114),"[email protected]"),((152,152),"[email protected]"),((76,76),"icon-76.png"),((58,58),"[email protected]"),((29,29),"icon-small.png"),((57,57),"icon.png"),((114,114),"[email protected]")]im = PIL.Image.open("1024.png")i = 0for i in range(len(imgNames)):imt = imsize = imgNames[i][0] #print sizename = imgNames[i][1]#print name+type(name)imt_r = imt.resize(size,PIL.Image.LANCZOS)imt_r.save(name)i = i+1


mac內建python環境(可能不包含PIL庫,需下載),使用終端相關命令即可產生:

1.cd至1024圖所在目錄,將以上代碼在相同目錄下用vi儲存為**.py

2.python **.py即可

3.其他尺寸需求,可自由在imgNames中修改

python自動產生iOS各尺寸規格icon

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.