Simple python command-line script that scales images to the targeted file size with minumum quality loss and preserving aspect ratio.
The script works by converting images to bitmaps and using a binary search to find the highest possible resolution that stays under the specified file size. Is it efficient? Not really. Is it simple? Definitely. If you just need to email images and stay within file size limits, it gets the job done.
Acceptable formats: .jpg, .jpeg, .png, .webp.
Scale a single image to 1 MB:
./imgs input.jpg 1Scale multiple images to 0.5 MB each:
./imgs photo1.jpg photo2.jpg 0.5Scale all .png files in the current directory to 0.8 MB and save them in the output/ folder:
./imgs *.png 0.8 -o output/This project is licensed under the GNU General Public License v3.0 – see the LICENSE file for details.
Developed by Stefan Bauer © 2025 Stefan Bauer. Licensed under GNU GPL v3.