It took me a lot of time to create a graphic in GIMP, and now I need to make some variations of the same graphic that actually only require the change of the FG color twice in the process.

The GIMP "raw" files are created as XCF. If I look inside (using Emacs), while it's a binary file, I can distinctly see a text command, like

  (fgcolor (color-rgba 0.000000 0.000000 0.000000 1.000000))

It would appear to me that GIMP stores - in its own binary format - a list of commands that it "replays" when the XCF is opened(?).

Maybe not - anyway my point is to have an editable list of "commands" (or similar) that could be text-editable, this way I would just change the two FG lines and a copy of the file to get the variations.

I need to repeat that process 10+ times, and such a text approach - Perl scriptable for instance - would save a lot of time.

Is it possible? Are there other ways to do this that do not require to open the XCF and repeat the whole long process while changing only the FG?

1 Answer 1


Here's what I would do:

  1. Look into creating a Gimp Script-fu, which is like a macro (link).
  2. If that doesn't work, try to find a solution using Imagemagick.
  3. In Gimp, export your entire image as something like: image.png
  4. Then adjust layer visibility so that only the foreground is showing, and everything else is transparent.
  5. Export this file as something like: image_foreground.png
  6. Now use imagemagick to change the colour of the foreground file and superimpose it on the background.
    1. Download appropriate binary (link) and follow installation instructions. Most linux distributions have it installed by default.

    2. Modify the colour of the foreground image (additional info):

          ### Don't have imagemagick right now. Will add code later. ###
    3. Overlay the new foreground onto the background (additional info):

          composite -gravity center image_foreground.png MyImage: image.png

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.