How to convert multiple XCF files to PNG?
Solution 1
One-liner from bash:
for i in *.xcf; do xcf2png -f $i -o $i.png; done
Solution 2
You can use GIMP Image editor and use Export to tool. Use Ctrl-Shift-E as shortcut.
Or you could use convert
from imagemagick
:
convert filename.xcf filename.png
You could also use xcftools
(sudo apt-get install xcftools), which has a utility called xcf2png
that does this job perfectly.
xcf2png image.xcf -o image.png
Solution 3
same of @k0pernikus, but remove xcf
extension from output filename
for i in *.xcf; do xcf2png -f $i -o "${i%.*}.png"; done
Solution 4
My one-liner using convert from imagemagik:
for i in Amplicon*.xcf; do convert $i ${i/xcf/png}; done
I had to keep my 'Amplicon' name because otherwise, it finds hidden xcf files in the directory and exports all the layers as individual PNGs haha. But it works! And the variant not using a loop (and could be parallelized)
find . -name "Amplicon*xcf" | xargs -I {} convert {} {}.png
But... I coudn't remove the '.xcf" from the filename. Still works!
Solution 5
Based on J. Auger's solution:
find . -name "Amplicon*xcf" | parallel convert {} {.}.png
Related videos on Youtube
k0pernikus
I am Philipp Kretzschmar, a backend developer from Hamburg working at Demvsystem. You can find me on github. Or twitter. My main weapons of choice are: php TypeScript (I don't want to write plain JavaScript anymore) and nodejs I play around with: Java python rust I used to write some scala, but for now I don't want to go there anymore. I feel most comfortable on a unix-like system featuring a powerful bash. (This excludes MacOS.) I love to code within JetBrains's flavored IDEs, e.g. IntelliJ, PhpStorm, WebStorm and using the IdeaVim plugin and having a docker-compose stack to develop on.
Updated on September 18, 2022Comments
-
k0pernikus over 1 year
I have a folder with a lot of
xcf
files which I want all to be converted topng
files, at best via a one-liner from bash.How can I achieve such a task?
-
Admin about 11 yearsWith xcf2png...
-
Admin about 11 years@jasonwryan Thanks, worked like a charm.
-
Admin about 11 yearsYou may want to give a try to
convert
tool from ImageMagick. Supports a lot of formats and operations, might be useful in future.
-
-
Wang almost 4 yearsdoes not work for xcf created by new gimp2, this tool is too old