Skip to content

Instantly share code, notes, and snippets.

@mhuneke
Created October 18, 2012 18:17
Show Gist options
  • Save mhuneke/3913886 to your computer and use it in GitHub Desktop.
Save mhuneke/3913886 to your computer and use it in GitHub Desktop.
Gimp batch scaling
import os, glob
import string
from gimpfu import *
scale_int = 8;
mime_type = 'jpg';
path = '/input-path/'
for infile in glob.glob( os.path.join(path, '*.' + mime_type) ):
image = pdb.gimp_file_load(infile, '1')
width = pdb.gimp_image_width(image)
height = pdb.gimp_image_height(image)
width = width / scale_int
height = height / scale_int
pdb.gimp_image_scale(image, width, height)
drawable = pdb.gimp_image_active_drawable(image)
temp_list = infile.split('/')
filename = temp_list.pop()
new_path = '/output-path/' + filename
pdb.gimp_file_save(image, drawable, new_path, 'Saved image')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment