Generating (Sony) Raw Thumbnails in Gnome
I sometimes manually move around pictures with Nautilus, and it had always bothered me that I had to open the file with Raw Therapee (which is slow to start-up and polutes the directory with .pp files) or use the files Creation Date for orientation.
Previous tries of mine to get this working have failed for yet unknown reasons, but in the end I got it working now after a lenghty and tedious session of trial and error, and sifting through tons of strace logs, which I hope this post will save you from.
Thumbnail Generation
In a nutshell the desktop environment creates thumbnails for files and stores them at a common location with the hash of the original file as key, so any other application can find it there and doesn’t need to calculate it over and over. If it is even able to do so, since this approach also enables apps to display thumbnails of files without needing to know how to actually read them.
In Gnome 3 this Cache is most commonly found in the Home Directory under .caches/thumbnails (some older apps sometimes also use .thumbnails also within the Home Directory) and divides up into size sub-folders (normal, large and failed ones in my case). The resulting thumbnails are plain PNG files with the URI of the source/original image written into the header.
Getting Started
There’s a package in the public Arch repo called raw-thumbnailer that can interpret RAW from the Sony α5100, so I’ll go with that:
# pacman -S raw-thumbnailer
If your Camera’s RAW files are not supported, maybe check out the ufraw-thumbnailer package in AUR, or if you want to generate thumbnails for some entirely different file format or are just looking for some general troubleshooting tipps, please have a look at this ridiculously comprehensive Ask Ubuntu answer.
All the Tutorials and other Posts I have found so far store their respective thumbnailer configs under /usr/share/thumbnailers, however in the strace logs I saw that Gnome also searches in the User Home under ~/.local/share/thumbnailers, which I like quite better, so I placed the descriptor file with the following content under ~/.local/share/thumbnailers/raw.thumbnailer:
[Thumbnailer Entry]
TryExec=/usr/bin/raw-thumbnailer
Exec=/usr/bin/raw-thumbnailer -s %s -o %o -i %i
MimeType=image/x-3fr;image/x-adobe-dng;image/x-arw;image/x-bay;image/x-canon-cr2;image/x-canon-crw;image/x-cap;image/x-cr2;image/x-crw;image/x-dcr;image/x-dcraw;image/x-dcs;image/x-dng;image/x-drf;image/x-eip;image/x-erf;image/x-fff;image/x-fuji-raf;image/x-iiq;image/x-k25;image/x-kdc;image/x-mef;image/x-minolta-mrw;image/x-mos;image/x-mrw;image/x-nef;image/x-nikon-nef;image/x-nrw;image/x-olympus-orf;image/x-orf;image/x-panasonic-raw;image/x-pef;image/x-pentax-pef;image/x-ptx;image/x-pxn;image/x-r3d;image/x-raf;image/x-raw;image/x-rw2;image/x-rwl;image/x-rwz;image/x-sigma-x3f;image/x-sony-arw;image/x-sony-sr2;image/x-sony-srf;image/x-sr2;image/x-srf;image/x-x3f;
Next we check if it worked by first clearing the cache using:
rm -rf ~/.caches/thumbnails/*
and then navigating to a directory with a RAW file and force thumbnail generation with Ctrl+R. You can see that the thumbnail generation is triggered, as the icon temporarily changes to a progress indicator for a mere glimpse before it gets replaced with either the final thumbnail or the MIME types default icon.
In my specific case only the image/x-sony-arw mime type is actually needed, I opted to register a few more types that are also supported by the raw-thumbnailer in case I need them in the future.
And here comes the obligatory after Screenshot:
Dead-Ends
While tinkering with the thumbnail generation, I stumbled into various older posts 1, 2 and threads that described solutions that were out-of-date, and even the official documentation is obsolete!
For instance some describe how to store the above thumbnail entry file into gconf, when gconf has been deprecated with Gnome 3 and software is supposed to transition to the new dconf and the thumbnailer declarations have moved into their own small files.
Also the thumbnail cache is now located under ~/.cache/thumbnails instead of ~/.thumbnails.
In short if a solution mentions gconf anywhere, it can be considered obsolete and skipped entirely.
Troubleshooting
- To verify thumbnail generation is even active you can check with strace.
$ strace nautilus . &> ~/nautilus.log
$ strace eog some_raw_file.arw &> ~/eog.log
In the resulting log you should see if /usr/share/thumbnailers is read at all, and if yes if any of the configs (especially yours) are found. Usually the thumbnail service will set a file notifier on the directories.
- While the thumbnails in the failed size bucket do show empty in EOG, they are valid, though empty, PNG files that also have the URI of their source image in their header. Nautilus metadata didn’t display them for me, but can be seen in a hex editor like bless. You can then navigate to the non-working file and try to manually invoke the thumbnailer like so:
$ raw-thumbnailer -i input_from_uri.arw -o output.png -s 128
- As already mentioned in the Ask Ubuntu answer, Nautilus can be completely closed with the -q parameter:
$ nautilus -q