Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple script to automatically downsize all the images in a folder using Gimp python console (Gimp->Filters/Python-Fu/console).
from os import listdir
from os.path import isfile, join
## Set image folder path
dir_path = "C:/img_dir/"
## Store files names in folder
files = [f for f in listdir(dir_path) if isfile(join(dir_path, f))]
for file in files:
image = pdb.file_jpeg_load(dir_path+file, dir_path+file)
## Don't forget to create the 'small/' folder in your image directory
save_path = dir_path+"small/"+ file
## save image with 85% of original quality
pdb.file_jpeg_save(image, image.active_drawable, save_path, save_path, 0.85, 0, 0, 0, "", 0, 0, 0, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment