I’ve been using GIMP-2.9 since 2012 and over the years accumulated a lot of XCF files scattered hither and yon. Fortunately I kept these XCF files sorted into “project folders” - one folder per finished image. The project folders contain a lot of different file types in addition to the XCF files, such as raw file “pp3/pfp/xml/etc”, output tiffs and exr files from the various raw processors, intermediate files exported from GIMP for processing in other software, jpegs for the web, and etc.
I spent some time pulling the project folders together into one top-level folder. The next step was to be able to view, tag, sort, and rate the accumulated final images and associated XCF files.
digiKam would be perfect for the task, except that digiKam (as of 5.7.1) crashes upon encountering GIMP-2.9 XCF files. This likely will continue to be the case until GIMP-2.10 has been released and kimageformats has been updated to support GIMP-2.10 XCF files (see Bug 782244 – Make XCF format more accessible to file managers and similar software).
In the meantime, the way to keep digiKam from crashing when it hits a GIMP-2.9 XCF file is to not install kimageformats, but of course you won’t see a thumbnail or a preview image. I worked around this problem by creating “png sidecar files” for all my GIMP-2.9 XCF files (details below).
Not installing kimageformats brings other problems:
-
Some Linux distributions likely won’t allow you to install digiKam without also installing kimageformats. Or even if digiKam can be installed without kimageformats, other KDE programs (for example Gwenview) might pull in kimageformats.
-
Kimageformats is required for digiKam to be able to recognize and make preview images not just for GIMP XCF files, but also for Krita kra files, OpenEXR files, PSD files, and several other image file formats.
So the workaround is to build and install kimageformats from source, after modifying the source code to make kimageformats not build whatever it builds to allow digiKam to recognize XCF files. And then XCF files can be added to digiKam as an unsupported file format, for which digiKam will provide a generic thumbnail and no preview image.
Here is how to modify kimageformats to keep digiKam from crashing on GIMP-2.9 XCF files:
Download the source code:
Stable:
KDE - Experience Freedom! and scroll down to kimageformats
git - surely there is a kde anongit link, but I can’t find it, I used the github version:
GitHub - KDE/kimageformats: KImageFormats
Modify the source code:
-
Open “src/imageformats/CMakeLists.txt” with a code or text editor (I use geany)
-
Find the following lines for XCF files:
##################################add_library(kimg_xcf MODULE xcf.cpp)
target_link_libraries(kimg_xcf Qt5::Gui)install(TARGETS kimg_xcf DESTINATION {KDE_INSTALL_QTPLUGINDIR}/imageformats/) install(FILES xcf.desktop DESTINATION {KDE_INSTALL_KSERVICES5DIR}/qimageioplugins/)
-
Comment out the lines for XCF files as follows, and save the modified file:
###################################add_library(kimg_xcf MODULE xcf.cpp)
#target_link_libraries(kimg_xcf Qt5::Gui)install(TARGETS kimg_xcf DESTINATION {KDE_INSTALL_QTPLUGINDIR}/imageformats/) #install(FILES xcf.desktop DESTINATION {KDE_INSTALL_KSERVICES5DIR}/qimageioplugins/)
-
Compile and install the source code. You are on your own for this step. It worked for me, but if your computer quits working after compiling and installing kimageformats, or if all your image files disappear, well, that’s a risk you take when you install software from source.
Unfortunately, at least on my Gentoo Linux system digiKam still can’t properly display Krita kra or OpenEXR files. That’s the bad news. The good news is that it no longer crashes when it reaches GIMP-2.9 XCF files.
- Now start digiKam. You might have to add “xcf” to the list of supported file types (“Settings/Configure digiKam/Views/Mime Types”). Now digiKam will import the XCF files without crashing, and simply display a generic thumbnail with no preview.
Which of course still doesn’t solve the problem of actually being able to view the contents of GIMP-2.9 XCF files. But an obvious workaround is to make “GIMP sidecar files” such as sidecar pngs or sidecar tiffs. This way one can view the contents via the sidecar files, write tags and such to the sidecar files, and also right-click the GIMP XCF generic thumbnail to directly open any given XCF file from within digiKam, or simply drag the XCF file from digikam to an already running GIMP-2.9 and drop it on the tool box.
Making GIMP XCF sidecar files:
To export the sidecar files I’m using a very slightly modified version of the last script from this post:
For the directory specified in the script, put in the path to the top level folder that you want the script to iterate over. And don’t forget to set the desired format for the exported sidecar file (png, tiff, etc). Also be sure to open GIMP and set whatever defaults you want GIMP to use for the output file type used in the script.
I debated back and forth between tiff and png sidecar files. The advantage of tiffs is that the tiffs will preserve the bit depth and precision of the XCF file. The advantage of pngs is that the bit depth will be at most 16-bit integer (smaller files sizes than 32-bit tiffs - almost all of my XCF files are at 32f precision). Also GIMP allows to set defaults for exporting pngs such as writing or not writing metadata to the exported pngs. This is not the case for exporting tiffs.
If you export pngs, I’d suggest setting the compression to 0 as the script takes much less time to execute if the pngs aren’t compressed by GIMP during the export. Then if you really want compressed pngs, use ImageMagick. But digiKam doesn’t have to decompress the png for display, if it’s not compressed in the first place. So I just left the pngs uncompressed.
Jpeg sidecar files also would work, but only if all of your GIMP XCF files are in perceptually uniform RGB color spaces such as regular sRGB. Otherwise the jpegs will have posterized shadows.
I decided to use uncompressed png sidecar files, with no metadata written to the files. Otherwise GIMP will export a lot of metadata taken from the original raw file (most of my images started as raw files), and all of that information is already in my digiKam database for the actual original camera files. Repeating all those tags for the files in the project folder would not be useful for my particular workflow.
Over in the following thread @Carmelo_DrRaw very kindly provided two very useful scripts if you want to take the sidecar files exported from GIMP, resize them to a fixed size, and convert them to a fixed color space:
For some workflows the resized and converted sidecar files from @Carmelo_DrRaw 's scripts would work very well. But shortly after getting all the resized sidecar files in place I realized that now I had no way to know the original dimensions of the corresponding XCF file, and also no way to know the RGB color space for XCF file, unless I actually open the XCF file. So I went back to the unmodified png sidecar files as directly output by GIMP. Sigh.
Displaying correct shadow tonality in digiKam for linear gamma RGB images:
This has been a lot of work to “work around” the fact that digiKam crashes upon encountering GIMP 2.9 XCF files. And I’m not done yet, because most of my XCF files - and also most of the other image files in the project folders - are all in linear gamma RGB working spaces, and digiKam as of 5.7.1 can’t correctly display the shadows of the previews for linear gamma images. It also trashes the shadows for the thumbnails, but that’s to be expected because at least to date thumbnails are always 8-bit images. See the very last posts to this thread for details: http://digikam.1695700.n4.nabble.com/Thumbnails-not-color-managed-severely-distorted-shadow-tonality-for-thumbs-previews-td4704410.html
Well, hopefully eventually the upstream digiKam code will provide a user switch to disable the LCMS optimizations (these optimizations are the reason digiKam incorrectly displays the shadow tonality for linear gamma images). But right now the only way to fix the problem of trashed shadows for linear gamma RGB images is to download the digiKam source code, modify one file, and then compile and install the modified code.
Stable:
git:
I used the code from git. After downloading the source code:
-
Open “core/libs/dimg/filters/icc/icctransform.cpp” and locate the line which reads:
transformFlags = 0;
-
Change it to read:
transformFlags = cmsFLAGS_NOOPTIMIZE;
-
Save the file and compile and install as usual.
You might want to take a look at bootstrap.linux to see if there are any compile options you might want to disable. You can also modify the lines that read as follows:
if [ “$DIGIKAM_INSTALL_PREFIX” == “” ]; then
DIGIKAM_INSTALL_PREFIX=“/usr/local”
and change the install prefix to whatever you want. I think it might default to “/usr”, but I changed it to “/usr/local”.
Concluding thoughts:
Well, while working out the details of getting digiKam and GIMP-2.9 to play nice together, I also managed to whittle down my total number of XCF files in the “projects” folders from around 1000 to around 450 - that’s progress! Plus it’s really nice to be able to use digiKam to navigate to a folder, pick an XCF file via the associated sidecar file, and open the XCF file from within digiKam.
As a bonus, I discovered that the same script that I used to output GIMP-2.9 XCF “sidecar” files, can be modified to open PhotoShop PSD files using GIMP-2.9 and output sidecar files for all the PSD files. I don’t have many PSD files left on my computer (well, it’s been a long time since I ran Windows, and most of the old PSD files got lost along the way). Most of the PSD files that are left weren’t saved with maximum compatibility, so digiKam didn’t show any thumbnail. So it was nice to be able to use GIMP to get an idea of what was actually in those old PSD files.
Anyway, my apologies for the long post. But there might be other people trying to organize a bunch of GIMP-2.9 XCF files, who would like to be able to use digiKam to organize, locate and open these XCF files. So hopefully this “how to” might be useful.