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.
Best Answer
I had no keys under desktop/gnome/tumbnailers in gconf-editor on 11.10 and 12.04. All thumbnails were generated normally, except for movies, because i uninstalled totem.
To use ffmpegthumbnailer i installed it like in upper post:
Then deleted thumbnail cache like in upper post:
I then made a change in /usr/share/thumbnailers/totem.thumbnailer
from this:
to this:
And exited nautilus:
It is all working great now. Hope it helps!
If thumbnails still fail to generate, you might need to add the following to /usr/share/thumbnailers/totem.thumbnailer:
And again run
nautilus -q
in terminal.