Python automatically generates iOS icons and pythonios
Use python to automatically generate iOS icons of various sizes (based on a 1024-inch image). The Code is as follows:
Import PIL. imageimgNames = [(), "icon-72.png"), (), "icon-40.png"), (80), "icon-40@2x.png"), (50 ), "icon-50.png"), (100,100), "icon-50@2x.png"), (60, 60), "icon-60.png"), (120,120), "icon-60@2x.png"), (180,180 ), "icon-60@3x.png"), (114,114), "icon-72.png"), (152,152), "icon-72@2x.png"), (), "icon-76@2x.png ), "icon-76.png"), (58,58), "icon-small@2x.png"), (29,29), "icon-small.png"), (57,57), "icon.png"), (114,114 ), icon@2x.png)] im = PIL. image. open ("1024.png") I = 0for I in range (len (imgNames )): IBD = imsize = imgNames [I] [0] # print sizename = imgNames [I] [1] # print name + type (name) imt_r = IBD. resize (size, PIL. image. LANCZOS) imt_r.save (name) I = I + 1
The mac built-in python environment (which may not contain the PIL library and needs to be downloaded) can be generated using terminal-related commands:
1. cd to the directory where the 1024 graph is located, save the above Code in the same directory as vi **. py
2. python **. py
3. Other dimension requirements can be freely modified in imgNames