Last active
April 22, 2020 00:08
-
-
Save saamerm/71de85f8f8de61a5fad88037a59b6a69 to your computer and use it in GitHub Desktop.
Image Resizer for Android & iOS App Icons
This file contains hidden or 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
#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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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