Nautilus's thumbnailing routines actually come from the libgnome-desktop
library, so it is possible to run the same thumbnailers outside of the file manager.
The API is a little complex, but the following Python script should help:
#!/usr/bin/python
import os
import sys
from gi.repository import Gio, GnomeDesktop
def make_thumbnail(factory, filename):
mtime = os.path.getmtime(filename)
# Use Gio to determine the URI and mime type
f = Gio.file_new_for_path(filename)
uri = f.get_uri()
info = f.query_info(
'standard::content-type', Gio.FileQueryInfoFlags.NONE, None)
mime_type = info.get_content_type()
if factory.lookup(uri, mtime) is not None:
print "FRESH %s" % uri
return False
if not factory.can_thumbnail(uri, mime_type, mtime):
print "UNSUPPORTED %s" % uri
return False
thumbnail = factory.generate_thumbnail(uri, mime_type)
if thumbnail is None:
print "ERROR %s" % uri
return False
print "OK %s" % uri
factory.save_thumbnail(thumbnail, uri, mtime)
return True
def thumbnail_folder(factory, folder):
for dirpath, dirnames, filenames in os.walk(folder):
for filename in filenames:
make_thumbnail(factory, os.path.join(dirpath, filename))
def main(argv):
factory = GnomeDesktop.DesktopThumbnailFactory()
for filename in argv[1:]:
if os.path.isdir(filename):
thumbnail_folder(factory, filename)
else:
make_thumbnail(factory, filename)
if __name__ == '__main__':
sys.exit(main(sys.argv))
Save this to a file and mark it executable. You may also need to install the gir1.2-gnomedesktop-3.0
package if it is not already installed.
After that, simply invoke the script with the files or folders you want to thumbnail as arguments. Thumbnails will be saved to ~/.thumbnails
where applications like Nautilus expect to find them.
This may happen if you get a different UID from the one you had before (this will remove you the ownership of those files). Try executing this on a terminal:
sudo chown -R $USER:$USER ~/.thumbnails
From 12.10 onward, thumbnais are also stored in ~/.cache/thumbnails
, so you may repeat the same process for this location.
If none of those solves your issue, you can always remove them (they are automatically generated, and I think failed thumbs generations are cached):
sudo rm -rf ~/.thumbnails/* ~/.cache/thumbnails/*
Note: it's not the case of OP, but if you don't get previews to video files (ex: mkv, mp4) probably you are missing the video codec. This can be easily fixed by open the video with "Movie Player": it will propose a suitable codec.
Best Answer
Perhaps you can try turning off thumbnail rendering as a workaround: in Nautilus go to Edit>Preferences>Preview, and try turning a few of those options off.
I asked a similar question in the Inkscape user forum, and got this answer:
AFAIK the library used by Nautilus to render the preview thumbnails for SVG files (librsvg) supports fewer SVG features than Inkscape, and chokes on certain filter effects and linked images (IIRC of type 'jpeg' or 'tiff'), and possibly other items too. See also: Bug #305546 in librsvg (Ubuntu): “Nautilus crashing/freezing when opening folder with svg file”. Nothing Inkscape can do about that-> needs to be addressed in Nautilus (don't freeze) and librsvg (handle failures to render certain SVG files more graciously).
The bug report is here: https://bugs.launchpad.net/ubuntu/+source/librsvg/+bug/305546. Does that sound familiar?