loading...


GIMP batch image scale ( GIMP actions )

GIMP automated scale actions

My problem was,  i had  mor than 2000+ images to resize.
And as GIMP don't has a automated actions batch i have made fast a very simple python script that will do the trick.

How to use

Set this vars in the script

  • You have to set the folder path to the images in the script 
  • Set the finished images path (best to a other folder, din't try to use te same folder yet.)
  • Set the scale value 

Set in GIMP

  • Goto Filter > Python-Fu > Console
  • Past the script in the console window 

 

# import python classes
import os, glob
import string

# import GIMP python class
from gimpfu import *

# the ammount to scale to
scale_int = 3;

# the mime-type without the dot (.)
mime_type = 'JPG';

#the path to the  file to optimize
path = '/set/your/path/to/photos-new/'

# here we do a foreach loop
for infile in glob.glob( os.path.join(path, '*.' + mime_type) ):

# load the image in the image object
image = pdb.gimp_file_load(infile, '1')

# get the current with & height of the image
width = pdb.gimp_image_width(image)

height = pdb.gimp_image_height(image)
# scale the image width and height

width = width / scale_int
height = height / scale_int

# here we scale the image object!
pdb.gimp_image_scale(image, width, height)

#have to lookup wath this is doin exacly
drawable = pdb.gimp_image_active_drawable(image)

# some simple string manipulations
temp_list = infile.split('/')

# pop the last object 'the filename' of the list
filename = temp_list.pop()

#Set a new path for the new-converted images
# - make sure you can write to the folder !

new_path = '/set/your/path/to/photos-new/' + filename

#here we save the file
pdb.gimp_file_save(image, drawable, new_path, 'Saved image')

 

Download the script
usage of this is at own risk

GIMP batch image scale script