Search code examples
command-linegimpscript-fu

Replace all my old xcf files by better compressed versions


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?


Solution

  • 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.