Skip to content

Instantly share code, notes, and snippets.

@saamerm
Last active April 22, 2020 00:08
Show Gist options
  • Save saamerm/71de85f8f8de61a5fad88037a59b6a69 to your computer and use it in GitHub Desktop.
Save saamerm/71de85f8f8de61a5fad88037a59b6a69 to your computer and use it in GitHub Desktop.
Image Resizer for Android & iOS App Icons
#This image resizer takes your image from the Python2 folder and resizes it based on code in the im.resize function
# You will have to install PIL using sudo pip3 install python-resize-image
from PIL import Image
import os, sys
# The path will need to be played around with, this code worked with my Mac
path = "/Users/saamer/Documents/Python2/"
dirs = os.listdir( path )
def resize():
for item in dirs:
if os.path.isfile(path+item):
im = Image.open(path+item)
f, e = os.path.splitext(path+item)
os.mkdir(f)
#Just create 2 new lines per image size required
imResize = im.resize((24,24), Image.ANTIALIAS)
imResize.save(f + '/24resized.png', 'PNG', quality=100)
imResize = im.resize((36,36), Image.ANTIALIAS)
imResize.save(f + '/36resized.png', 'PNG', quality=100)
resize()
@saamerm
Copy link
Author

saamerm commented Jul 3, 2019

Screen Shot 2019-07-03 at 11 07 18 AM
Here's the folder and contents that you get when you run the command python resizer.py

RIP icon.angrymarmot.org, you helped a lot. Thank you python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment