Skip to content

Instantly share code, notes, and snippets.

@weshouman
Forked from amatelin/gimp_img_downsize.py
Created November 29, 2020 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weshouman/c8c7950a94051aa2407d2a9888b61007 to your computer and use it in GitHub Desktop.
Save weshouman/c8c7950a94051aa2407d2a9888b61007 to your computer and use it in GitHub Desktop.
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