Skip to content

Instantly share code, notes, and snippets.

@YiqinZhao
Created August 2, 2020 19:03
Show Gist options
  • Save YiqinZhao/d35ac3f639c5c706b7270d205246ff4e to your computer and use it in GitHub Desktop.
Save YiqinZhao/d35ac3f639c5c706b7270d205246ff4e to your computer and use it in GitHub Desktop.
Generate icon with multiple scaled size for Apple platform.
from PIL import Image
img = Image.open('./icon.png')
sizes = [16, 32, 128, 256, 512]
for s in sizes:
img_resized = img.resize((s, s))
img_resized.save(f'./dist/icon-{s}x{s}@1x.png')
t = s * 2
img_resized = img.resize((t, t))
img_resized.save(f'./dist/icon-{s}x{s}@2x.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment