2

I'm using GIMP to do a simple but tedious operation for many images so I'd like to know how I can make a script that will do it for me, or find some simpler way of doing this.

I import an image file that has large dimensions but is mostly square, sometimes like 550x564, 580x596, etc., which may be jpg, bmp, or png, and I want to export a 192x192 PNG file, resized and cropped on both ends of the longer dimension, which is usually vertical but can be horizontal.

I perform the following steps for an image that is longer vertically than it is horizontally:

  1. Image->Scale Image->Set Width to 192 (Locked, so Height will automatically be set to something like 196)
  2. Click Scale
  3. Image->Canvas Size->Set Height to 192
  4. Click Center
  5. Click Resize
  6. File->Export As->same file name but extension changed to .png, and PNG image selected from the dropdown list (usually the original files are jpg, but sometimes they are png, so overwrite if necessary)
  7. Click Export
  8. (Click Load Defaults)
  9. Click Export again

I've looked at some tutorials for creating scripts, but they seem to require external plugins. Is there no way I can do it without downloading a new file? If I should download and use a plugin, what is the best one for this type of thing?

Is there any macro recorder that will let me do something like this:

  1. Start the macro recorder
  2. Perform the operations once on a sample file
  3. Stop the macro recorder
  4. Import a new file
  5. Press play on the macro recorder
  6. etc

Or is it possible to make a script that will do these operations on all files in a directory?

  • GIMP's website says Script-fu and Python scripting are both built into GIMP by default, but I couldn't seem to get it working. I guess I had customized the installation and not installed either of them. I reinstalled and so now I have them working, but it's quite difficult to figure out how to make a script that will do what I need – user120525 May 1 '18 at 10:17
3

No, there is no macro-recorder in Gimp. It can be scripted with Script-fu (a LISP/Scheme derivative) or Python. I find Python simpler to use and it can do more things. Both are now built-in and don't need any additions to your standard Gimp installs.

Gimp scripts can call installed plug-ins (in fact many things in standard Gimp are plug-ins already) but they can also work with the base APIs. For what you want to do there is no need for any plugins.

But also, for what you want to do, using Gimp is plain overkill, it would be better/faster done with a plain CLI utility such as ImageMagick (ok, there is learning curve, but writing Gimp scripts also has a rather steep learning curve). Ask what you want to do on StackOverflow with an ImageMagick tag...

If you want to stick with Gimp, two StackOverflow questions that can answer a lot of your questions here and there.

PS: you can see if your Gimp is enabled for Script-fu or Python by looking for Script-fu and Python-fu submenus in Filters. Both have a Console entry that elicits a window where you can try commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy