Converting XCF and other files using command line with GIMP?

I guess ImageMagick should do what you want (and even more)

convert image.xcf image.png

A very good solution (and explanations!) can be found here. In short, there is a bash script feeding scheme/lisp to gimp

#!/bin/bash
{
cat <<EOF
(define (convert-xcf-to-jpeg filename outfile)
  (let* (
     (image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
     (drawable (car (gimp-image-merge-visible-layers image CLIP-TO-IMAGE)))
     )
    (file-jpeg-save RUN-NONINTERACTIVE image drawable outfile outfile .9 0 0 0 " " 0 1 0 1)
    (gimp-image-delete image) ; ... or the memory will explode
    )
)

(gimp-message-set-handler 1) ; Messages to standard output
EOF

for i in *.xcf; do
  echo "(gimp-message \"$i\")"
  echo "(convert-xcf-to-jpeg \"$i\" \"${i%%.xcf}.jpg\")"
done

echo "(gimp-quit 0)"
} | gimp -i -b -

But look at the page for the full story. It's worth it.


I'm a couple of years late, but I thought I'd add what I think is by far the best solution: there is a tool suite called Xcftools (on Ubuntu, apt-get install xcftools), which has a utility called xcf2png that does this job perfectly.

xcf2png image.xcf -o image.png

This is much better than a) using ImageMagick (which as I said in a comment above is horribly broken), or b) using Gimp (which has an extremely complicated scripting language for simply exporting an image).