Last active
August 29, 2015 14:20
-
-
Save ayushgoel/dd403e658162f8466532 to your computer and use it in GitHub Desktop.
Convert one image to all required sizes for iOS icons and artwork with understandable names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import PIL.Image as Image | |
import sys | |
extension = ".png" | |
def saveImage(image, imageName): | |
image.save(imageName + extension) | |
IconNamePrefix = "Icon" | |
IconSizes = [(58, 58), (80, 80), (87, 87), (120, 120), (180, 180)]; | |
def convertImageToIcons(image): | |
for size in IconSizes: | |
convertedImage = image.resize(size, Image.ANTIALIAS) | |
saveImage(convertedImage, IconNamePrefix + str(size[0])) | |
ArtworkNamePrefix = "iTunesArtwork" | |
ArtworkSizes = [(512, 512), (1024, 1024)]; | |
def convertImageToArtwork(image): | |
for size in ArtworkSizes: | |
artwork = image.resize(size, Image.ANTIALIAS) | |
artworkSuffix = '@2x' if size[0] > 512 else '' #I hate this line | |
saveImage(artwork, ArtworkNamePrefix + artworkSuffix) | |
if __name__ == '__main__': | |
imageName = sys.argv[1] | |
image = Image.open(imageName) | |
convertImageToIcons(image) | |
convertImageToArtwork(image) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment