Hello all - I’ve used GIMP several years for a variety of basic image needs at work, and have always been able to navigate through reasonably well before now.
I have 400 EPS files that I need to apply the following processing steps to. Because they’re pretty large (3.6GP apiece), I need to set up my machine overnight to run a batch instead of handling them by hand. The steps I need to apply are:
(1) Import the EPS file at 7200dpi.
(2) Crop to Content.
(3) Resize to 16384px width by scaled height using LoHalo interpolation.
(4) Flatten image layers to remove Alpha (transparent → white).
(5) Convert to indexed palette (optimal 255 colors), using no dithering.
(6) Export as BMP with run-length-encoding enabled and write color space info disabled.
(7) Repeat the above for all 400 EPS files in the same directory.
I’m using 3.02r1 on a Windows 11 machine, and I tried to write the script (meaning I fed the requirements into ChatGPT); it gave me the following Python-Fu, which I then dumped into batch-process-eps.scm in my Scripts folder, per Preferences–>Folders–>Scripts. But after a restart, the script didn’t appear in GIMP, including in a search, so there’s something missing.
I’m relatively familiar with R, VBA, SQL and some other programming languages, so scripting isn’t alien to me, and I could figure this out eventually (probably). But any help is appreciated. Maybe it needs to be Script-Fu instead of Python-Fu, or something needs modified, or I’m not registering it correctly. Or all three. Regardless, help is appreciated! Thank you.
#!/usr/bin/env python
from gimpfu import *
import os
def batch_process_eps(input_dir):
# Get all EPS files in directory
eps_files = [f for f in os.listdir(input_dir) if f.lower().endswith('.eps')]
for eps_file in eps_files:
input_path = os.path.join(input_dir, eps_file)
output_path = os.path.splitext(input_path)[0] + '.bmp'
# Load EPS with high resolution
image = pdb.file_eps_load(input_path, input_path, 7200.0)
# Crop to content
pdb.plug_in_autocrop(image, image.active_layer)
# Get current width for scaling ratio calculation
current_width = image.width
target_width = 16384
scale_ratio = float(target_width) / float(current_width)
new_height = int(image.height * scale_ratio)
# Scale image using LoHalo
pdb.gimp_image_scale_full(image, target_width, new_height, INTERPOLATION_LOHALO)
# Flatten image
image.flatten()
# Convert to indexed
pdb.gimp_image_convert_indexed(
image, # The image
NO_DITHER, # No dithering
MAKE_PALETTE, # Use optimal palette
255, # Number of colors
False, # No alpha
False, # No remove unused
"" # No palette name
)
# Export as BMP with RLE and no color space info
pdb.file_bmp_save(
image,
image.active_layer,
output_path,
output_path,
True, # Run-length encoded
False # Do not write color space information
)
# Close the image
pdb.gimp_image_delete(image)
# Quit GIMP
pdb.gimp_quit(0)
# Register the script
register(
"batch_process_eps",
"Batch process EPS files",
"Process EPS files with specific parameters",
"Your Name",
"Your Name",
"2025",
"Batch Process EPS",
"",
[
(PF_DIRNAME, "input_dir", "Input directory", "")
],
[],
batch_process_eps,
menu="<Image>/File/Batch Process EPS"
)
main()