1

The xcf "better but slower compression" that came out since 2.10 is pretty darn efficient. I have many old and heavy xcf files in my hard drive and would like to replace them all by their better compressed version with a terminal command. Is that possible?

1 Answer 1

2

Your mileage may vary. On my latest Gimp 2.8 file:

Plain Gimp 2.8 format:       15760K
Compressed Gimp 2.10 format: 11220K
GZipped Gimp 2.8 format:     11756K
BZipped Gimp 2.8 format:      9804K
XZipped Gimp 2.8 format:      9460K

The Gzipped/BZipped/XZipped formats are obtained by: {gzip/bzip2/xz} Gimp2.78-file.xcf

This produces Gimp2.78-file.xcf.{gz/bz2/xz} files that Gimp 2.8 and Gimp 2.10 can open directly without having to un-compress them first (these three formats can also be produced directly by Gimp)(*).

So you can save equivalent or more space and still keep a 2.8 compatibility by just running gzip *.xcf or bzip2 *.xcf or xz *.xcf in your directories.

gzip/bzip2/xz are rather standard issue on Linux, but there are Windows/MacOS versions.

You can drop the dot in the extension (.xcfgz, .xcfbz2, .xcfxz), this makes it easier to associate the files with Gimp.

PS: as to writing a script to load/save the images, tough luck, there is no option in the current XCF save API to trigger the 2.10 compression, 2.8 images are re-saved in 2.8 format, and changing layer modes to enforce 2.10 format doesn't trigger compression either.

7
  • oh that's even better! I didn't expect Gimp would read them without prior decompressing with another app. thanks Commented Feb 5, 2020 at 18:22
  • btw holy molly the xz compression is really not worth it. In my test file it took 7 times longer to compress than bz2 for a file that turns 99.7% smaller than the bz2. Commented Feb 5, 2020 at 18:32
  • and crazy thing: you can compress even more by first exporting the xcf with "better but slower compression" in GIMP 2.10 and then compressing that xcf with bzip 2! Commented Feb 6, 2020 at 8:11
  • So my question still has some value : can we perform this new compression from the command line? Commented Feb 6, 2020 at 8:17
  • 2
    bz2 compression makes a 2.10 compressed xcf a tiny bit larger,. Expected behavior. A well compressed file looks like completely random bytes, so cannot be compressed further. The 2nd compression only adds its control blocks tot the output.
    – xenoid
    Commented Feb 6, 2020 at 16:45

Your Answer

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

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