Download the free simple image resizer program in our shop.
By downloading the and running the files below, you assume all responsibly for running and operating the software. Thinktwisted.com and its proprietors assume no responsibility or liability for lost data, damaged systems, or corrupted information.
- Simple imageResizer.py – The original python image resizer script
- Simple imageResizer.exe – the Windows 10 executable
- Simply copy the .py or .exe into the folder containing images
- Double click the .py or .exe to launch the program.
- Enter the resize percentage in the pop up box (0-100) with no “%” sign.
- Sit back for a few seconds to a few minutes, depending on the number of images.
- Click Ok on the pop telling you how many images were resized.
- Enjoy your new found hard drive space.
I recently was faced with a completely full hard drive on one of my PCs. I had a large collection of images that I needed to keep for future reference, but many of them were saved in their original high quality resolution and format. It wasn’t necessary for me to keep the original high quality files, and going through 1000s of images manually to resize was out of the question.
I was unable to find a program to quickly and automatically resize all the images in a given directory, so I wrote my own.
This simple python program uses pillow and pyautogui to:
- Ask the user to enter a resize percentage (0 to 100).
- Iterates through all PNG and JPEG objects in the root directory and resizes (overwrites original) based on the input from step 1.
- Skips any image that is already under 1MB in size.
- Reports to the user how many images were resized.
See the code snippet below, or the full project on Github – https://github.com/thinktwisted/imageresizer
#! python3 # imageResizer.py - resizes all images in a folder based on user input import os import pyautogui as gui from PIL import Image # Prompt the user for the resize percentage prompt = gui.prompt('What is the resize percent?') scale = int(prompt)/100 count = 0 # Loop over all the files in the current directory for filename in os.listdir('.'): if not (filename.endswith('.png') or filename.endswith('.jpg') or \ filename.endswith('.PNG') or filename.endswith('.JPG') or \ filename.endswith('.jpeg') or filename.endswith('.JPEG')): continue # skips files that are not images if os.stat(filename).st_size/1000 < 1024: continue # skips files that are under 1MB already im = Image.open(filename) width, height = im.size print("Risizing " + filename + "...") im = im.resize((int(width*scale), int(height*scale))) im.save(filename) count += 1 # increment counter print(str(count) + ' images resized.') gui.alert(str(count) + ' images resized.', 'FINISHED!')