General installation instructions
Thumbnailers in repositories and PPAs
A number of thumbnailers are pre-packaged and can be easily installed from the software center or the command line. These thumbnailers don't require any additional configuration and should work right after restarting nautilus. You can do so with:
nautilus -q
Please consider reading these Q&As before installing anything from a PPA:
What are PPAs and how do I use them?
Are PPA's safe to add to my system and what are some "red flags" to watch out for?
Custom thumbnailing scripts on Ubuntu 11.04 and above
Custom thumbnailers that aren't available in repositories have to be installed manually. These are the steps you will have to take to install them:
Check out whether the script has any dependecies listed. If so, install them first.
Download the script and make it executable with chmod a+x filethumbnailer
or via Nautilus
Designate a folder in your file system for all future thumbnailers and move the script to it, e.g.
mkdir $HOME/.scripts/thumbnailers && mv filethumbnailer $HOME/.scripts/thumbnailers
Next you will have to register your script with Nautilus. To do so create a thumbnailer entry in /usr/share/thumbnailers
. The entry should follow the naming scheme foo.thumbnailer
where foo
is an expression of your choice (here file
):
gksudo gedit /usr/share/thumbnailers/file.thumbnailer
The thumbnailer specifications follow this scheme:
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/file.thumbnailer %i %o %s
MimeType=application/file;
The Exec
entry points to your thumbnailer script while the MimeType
field designates the related MimeTypes. Possible variables are:
%i Input file path
%u Input file URI
%o Output file path
%s Thumbnail size (vertical)
The specifications and variables will vary with each script. Simply copy and paste the content of the respective text box into the file and save it.
The thumbnailers should be up and running after restarting nautilus (nautilus -q
).
Custom thumbnailing scripts on Ubuntu 11.04 and below
Earlier versions of Ubuntu rely on GConf for thumbnailer associations. See here for more information.
Sources:
https://live.gnome.org/ThumbnailerSpec
https://bugzilla.redhat.com/show_bug.cgi?id=636819#c29
https://bugs.launchpad.net/ubuntu/+source/gnome-exe-thumbnailer/+bug/752578
http://ubuntuforums.org/showthread.php?t=1881360
Thumbnailers by file type
CHM files
Overview
Description: With this script you'll get thumbnails of your chm files
in the nautilus file manager. The script uses the largest image from
the homepage of the chm file to generate the thumbnail, usually this
will be an image of the front cover.
Creator: monraaf
(http://ubuntuforums.org/showthread.php?t=1159569)
Dependencies: sudo apt-get install python-beautifulsoup python-chm imagemagick
Thumbnailer entry
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/chmthumbnailer %i %o %s
MimeType=application/vnd.ms-htmlhelp;application/x-chm;
Script
#!/usr/bin/env python
import sys, os
from chm import chm
from BeautifulSoup import BeautifulSoup
class ChmThumbNailer(object):
def __init__(self):
self.chm = chm.CHMFile()
def thumbnail(self, ifile, ofile, sz):
if self.chm.LoadCHM(ifile) == 0:
return 1
bestname = None
bestsize = 0
base = self.chm.home.rpartition('/')[0] + '/'
size, data = self.getfile(self.chm.home)
if size > 0:
if self.chm.home.endswith(('jpg','gif','bmp')):
self.write(ofile, sz, data)
else:
soup = BeautifulSoup(data)
imgs = soup.findAll('img')
for img in imgs:
name = base + img.get("src","")
size, data = self.getfile(name)
if size > bestsize:
bestsize = size
bestname = name
if bestname != None:
size, data = self.getfile(bestname)
if size > 0:
self.write(ofile, sz, data)
self.chm.CloseCHM()
def write(self, ofile, sz, data):
fd = os.popen('convert - -resize %sx%s "%s"' % (sz, sz, ofile), "w")
fd.write(data)
fd.close()
def getfile(self,name):
(ret, ui) = self.chm.ResolveObject(name)
if ret == 1:
return (0, '')
return self.chm.RetrieveObject(ui)
if len(sys.argv) > 3:
chm = ChmThumbNailer()
chm.thumbnail(sys.argv[1], sys.argv[2], sys.argv[3])
EPUB files
Overview
Description: epub-thumbnailer is a simple script that tries to find a cover in an epub file and creates a thumbnail for it.
Creator: Mariano Simone
(https://github.com/marianosimone/epub-thumbnailer)
Dependencies: none listed, worked fine right away
Thumbnailer Entry
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/epubthumbnailer %i %o %s
MimeType=application/epub+zip;
Script
#!/usr/bin/python
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Author: Mariano Simone (marianosimone@gmail.com)
# Version: 1.0
# Name: epub-thumbnailer
# Description: An implementation of a cover thumbnailer for epub files
# Installation: see README
import zipfile
import sys
import Image
import os
import re
from xml.dom import minidom
from StringIO import StringIO
def get_cover_from_manifest(epub):
img_ext_regex = re.compile("^.*\.(jpg|jpeg|png)$")
# open the main container
container = epub.open("META-INF/container.xml")
container_root = minidom.parseString(container.read())
# locate the rootfile
elem = container_root.getElementsByTagName("rootfile")[0]
rootfile_path = elem.getAttribute("full-path")
# open the rootfile
rootfile = epub.open(rootfile_path)
rootfile_root = minidom.parseString(rootfile.read())
# find the manifest element
manifest = rootfile_root.getElementsByTagName("manifest")[0]
for item in manifest.getElementsByTagName("item"):
item_id = item.getAttribute("id")
item_href = item.getAttribute("href")
if "cover" in item_id and img_ext_regex.match(item_href.lower()):
cover_path = os.path.join(os.path.dirname(rootfile_path),
item_href)
return cover_path
return None
def get_cover_by_filename(epub):
cover_regex = re.compile(".*cover.*\.(jpg|jpeg|png)")
for fileinfo in epub.filelist:
if cover_regex.match(os.path.basename(fileinfo.filename).lower()):
return fileinfo.filename
return None
def extract_cover(cover_path):
if cover_path:
cover = epub.open(cover_path)
im = Image.open(StringIO(cover.read()))
im.thumbnail((size, size), Image.ANTIALIAS)
im.save(output_file, "PNG")
return True
return False
# Which file are we working with?
input_file = sys.argv[1]
# Where do does the file have to be saved?
output_file = sys.argv[2]
# Required size?
size = int(sys.argv[3])
# An epub is just a zip
epub = zipfile.ZipFile(input_file, "r")
extraction_strategies = [get_cover_from_manifest, get_cover_by_filename]
for strategy in extraction_strategies:
try:
cover_path = strategy(epub)
if extract_cover(cover_path):
exit(0)
except Exception as ex:
print "Error getting cover using %s: " % strategy.__name__, ex
exit(1)
EXE files
Overview
Description: gnome-exe-thumbnailer is a thumbnailer for Gnome that will give Windows .exe files an icon based on their embedded icon and
a generic "Wine program" icon. If the program has normal execute
permissions, then the standard embedded icon will be shown. This
thumbnailer will also give a thumbnail icon for .jar, .py, and similar
executable programs.
Availability: official repositories
Installation
sudo apt-get install gnome-exe-thumbnailer
ODP/ODS/ODT and other LibreOffice and Open Office files
Overview
Description: ooo-thumbnailer is a LibreOffice, OpenOffice.org and Microsoft Office document thumbnailer that can be used by Nautilus to
create thumbnails for your documents, spreadsheets, presentations and
drawings.
Availability: developer's PPA (most recent version that's compatible with LibreOffice in Ubuntu 12.04 and up)
Installation
sudo add-apt-repository ppa:flimm/ooo-thumbnailer && apt-get update && apt-get install ooo-thumbnailer
.xpm
images? I assumed they were as "standard" aspng
,jpg
andbmp
, but Nautilus does not generate previews for them. – MestreLion Apr 29 '13 at 02:10/* XPM */
header, even ifeog
displays them fine – MestreLion Apr 29 '13 at 18:07file -i FILE
– Wilf May 28 '14 at 21:51