Using ChatGPT to Write GIMP Script-Fu Scripts
Writing Script-Fu by hand is slow, because Scheme is unfamiliar and the GIMP procedure database is enormous. A chat assistant can shortcut most of that, as long as you know what it gets wrong.
- Always state your GIMP version. Version 3 changed several signatures.
- Ask for Python-Fu if you can. There is far more Python in its training data.
- It will invent procedure names that do not exist. Check every one.
- Verify with the Procedure Browser before running anything.
- Test on three copied files, never on your originals.
What It Is Good At
- The loop structure. Open a folder, process each file, save, close. This part it gets right consistently.
- Translating an idea into steps. Describe the job in plain English and it produces a sensible sequence.
- Explaining existing code. Paste a script you found and ask what each line does.
- Debugging. Give it the exact error and the script and it usually finds the problem.
- Converting between the two languages. Script-Fu to Python-Fu and back.
What It Gets Wrong
These are consistent, and knowing them turns a frustrating session into a productive one.
| Mistake | What it looks like | How to catch it |
|---|---|---|
| Invented procedure names | A call like gimp-image-auto-enhance that sounds right and does not exist | Search the Procedure Browser for every name |
| Wrong argument count | Procedure execution failed at runtime | The Procedure Browser lists the exact arguments |
| Version mismatch | Works in 2.10, errors in GIMP 3 or the reverse | State your version in the prompt |
| Photoshop logic | Talks about adjustment layers or actions, which GIMP does not have | Check it against the Photoshop translator |
| Missing image cleanup | GIMP runs out of memory partway through a large batch | Every loop needs gimp-image-delete at the end |
How to Prompt It
A vague request gets vague code. This template gets working code most of the time.
I am using GIMP 2.10 on Linux.
Write a Script-Fu batch script that:
- reads every .jpg file from /home/me/photos
- scales each one so the width is at most 1600 pixels, keeping the aspect ratio
- applies an unsharp mask with radius 2
- saves the result into /home/me/photos/out with the same filename
- does not modify the original files
Requirements:
- use only procedures that exist in GIMP 2.10
- flatten the image before saving
- call gimp-image-delete on every image after saving
- give me the command line to run it in batch mode
The four things that make this work:
- State the version and platform. Without it you get an answer for whichever version dominated its training data.
- List the steps as bullet points. Prose gets misread. Bullets do not.
- Give real paths. Placeholder paths get copied into the script and forgotten.
- Ask for the run command too. Otherwise you have a script and no way to run it.
Verify Before You Run
Two minutes here saves losing a folder of photographs.
- Open Filters, Script-Fu, Console in GIMP.
- Click the Browse button. That is the Procedure Browser.
- Search for each procedure name in the script.
- If a name is not there, it does not exist. Ask for a correction, naming the procedure.
- If it is there, check the argument list matches what the script passes.
This one habit converts most of the frustration people report with AI generated GIMP scripts into a two minute check.
Then Test Properly
- Make a test folder with three copies of real files.
- Point the script at that folder.
- Run it and check the output carefully, not just that it produced files.
- Only then point it at the real folder.
- Always write to a different output folder than you read from.
Debugging With It
This is where an assistant is genuinely reliable, because the error message gives it something concrete to work with.
| Error | What it usually means |
|---|---|
| Error: eval: unbound variable | A procedure name is wrong or does not exist in your version |
| Procedure execution failed | Wrong number of arguments, or the output folder is missing |
| Nothing happens, no error | The file glob matched nothing. Check the path and extension case. |
| Only some files processed | Extensions are case sensitive. JPG and jpg are different. |
| GIMP runs out of memory | Missing gimp-image-delete inside the loop |
Paste the full error and the full script. Partial context produces partial answers.
When to Skip the Assistant
For common jobs, a verified recipe beats generated code every time. The Script-Fu generator has ten batch recipes that were written and checked by hand: resize a folder, convert formats, make thumbnails, watermark, sharpen, greyscale, autocrop, add borders, rotate, and export XCF to PNG.
Use the assistant for the jobs those do not cover, and for editing an existing recipe into something new.
The scripting and automation guide covers Script-Fu from the beginning, and the Python-Fu guide covers the Python side.
Common Questions
Why does the script it gives me not work?
Usually one of three things. It used a procedure name from a different GIMP version, it guessed at an argument list, or it produced Photoshop style logic that has no GIMP equivalent. Check every procedure name in the Procedure Browser.
Which GIMP version should I say I am using?
Always state it explicitly. GIMP 3 changed several procedure signatures, and a model given no version will usually answer for 2.10.
Is it better at Script-Fu or Python-Fu?
Python-Fu, generally, because there is far more Python in its training data. Script-Fu uses Scheme, which is much rarer.
Can it debug an error for me?
Yes, and this is where it is most reliable. Paste the exact error message and the script, and it usually identifies the problem quickly.
Explore on GIMP.cc
Step-by-step GIMP guides for every skill level.
Resize, compress, convert, and check images online.
Answers to the most common GIMP questions.
Share this article: