还有哪些可用的缩略图以及如何安装它们?

问题

Ubuntu的文件管理器Nautilus对文件预览提供了广泛的支持。 这些缩略图由称为缩略图的助手程序处理。

预安装Ubuntu的缩略图数量有限,因此默认情况下不会呈现一些更奇特的文件类型。

在这些情况下,我可以安装哪些其他缩略图来激活预览?


相关问答

如何指示Nautilus预先生成缩略图?


注意

通过编辑社区维基答案,随意为此列表做出贡献。 如果您这样做,请遵循此Meta讨论中的指导原则并使用预先存在的模式来保持答案的一致性。

一般安装说明


存储库和PPA中的缩略图

许多缩略图都是预打包的,可以从软件中心或命令行轻松安装。 这些缩略图不需要任何其他配置,并且应该在重新启动nautilus后立即工作。 您可以这样做:

 nautilus -q 

在安装PPA之前,请考虑阅读这些问答:

什么是PPA以及如何使用它们?

PPA是否可以安全地添加到我的系统中,需要注意哪些“危险信号”?

Ubuntu 11.04及更高版本上的自定义缩略图脚本

必须手动安装存储库中不可用的自定义缩略图。 以下是安装它们时必须采取的步骤:

检查脚本是否列出了任何dependecies。 如果是这样,请先安装它们。

下载脚本并使用chmod a+x filethumbnailer或通过Nautilus使其可执行

在文件系统中为所有未来的缩略图指定一个文件夹,并将脚本移动到该文件夹​​,例如

mkdir $HOME/.scripts/thumbnailers && mv filethumbnailer $HOME/.scripts/thumbnailers

接下来,您必须使用Nautilus注册脚本。 为此,请在/usr/share/thumbnailers创建一个缩略图条目。 该条目应遵循命名方案foo.thumbnailer ,其中foo是您选择的表达式(此处为file ):

 gksudo gedit /usr/share/thumbnailers/file.thumbnailer 

缩略图规格遵循以下方案:

 [Thumbnailer Entry] Exec=$HOME/.scripts/thumbnailers/file.thumbnailer %i %o %s MimeType=application/file; 

Exec条目指向您的缩略图脚本,而MimeType字段指定相关的MimeTypes。 可能的变量是:

 %i Input file path %u Input file URI %o Output file path %s Thumbnail size (vertical) 

规范和变量将随每个脚本而变化。 只需将相应文本框的内容复制并粘贴到文件中并保存即可。

重启nautilus( nautilus -q )后,缩略图应该启动并运行。

Ubuntu 11.04及更低版本上的自定义缩略图脚本

早期版本的Ubuntu依赖GConf进行缩略图关联。 有关更多信息,请参见此处


资料来源

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



按文件类型的缩略图


CHM文件

概观

说明 :使用此脚本,您将获得nautilus文件管理器中chm文件的缩略图。 该脚本使用chm文件主页中的最大图像来生成缩略图,通常这将是封面的图像。

创作者 :monraaf( http://ubuntuforums.org/showthread.php?t=1159569

依赖关系sudo apt-get install python-beautifulsoup python-chm imagemagick

缩略图条目

 [Thumbnailer Entry] Exec=$HOME/.scripts/thumbnailers/chmthumbnailer %i %o %s MimeType=application/vnd.ms-htmlhelp;application/x-chm; 

脚本

 #!/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文件

概观

说明 :epub-thumbnailer是一个简单的脚本,它试图在epub文件中查找封面并为其创建缩略图。

创作者 :Mariano Simone( https://github.com/marianosimone/epub-thumbnailer

依赖关系 :没有列出,立即工作正常

缩略图输入

 [Thumbnailer Entry] Exec=$HOME/.scripts/thumbnailers/epubthumbnailer %i %o %s MimeType=application/epub+zip; 

脚本

 #!/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 . # 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文件

概观

描述 :gnome-exe-thumbnailer是Gnome的缩略图,它将为Windows .exe文件提供基于其嵌入图标和通用“Wine程序”图标的图标。 如果程序具有正常的执行权限,则将显示标准嵌入式图标。 该缩略图还将为.jar,.py和类似的可执行程序提供缩略图图标。

可用性 :官方存储库

安装

 sudo apt-get install gnome-exe-thumbnailer 

ODP / ODS / ODT以及其他LibreOffice和Open Office文件

概观

描述: ooo-thumbnailer是一个LibreOffice,OpenOffice.org和Microsoft Office文档缩略图,Nautilus可以使用它来为您的文档,电子表格,演示文稿和绘图创建缩略图。

可用性 :开发人员的PPA(最新版本与Ubuntu 12.04及更高版本中的LibreOffice兼容)

安装

 sudo add-apt-repository ppa:flimm/ooo-thumbnailer && apt-get update && apt-get install ooo-thumbnailer 

ICNS文件(Mac OSX图标)

概观

由于一些错误 ,Nautilus不会为Mac OSX图标生成缩略图,但是GdkPixbuf内置了支持。

脚本

这是为.icns文件生成缩略图的基本脚本。 可以在https://github.com/MestreLion/icns-thumbnailer找到更强大的版本

 #!/usr/bin/env python import sys from gi.repository import GdkPixbuf inputname, outputname, size = sys.argv[1:] pixbuf = GdkPixbuf.Pixbuf.new_from_file(inputname) scaled = GdkPixbuf.Pixbuf.scale_simple(pixbuf, int(size), int(size), GdkPixbuf.InterpType.BILINEAR) scaled.savev(outputname, 'png', [], []) 

安装

.thumbnailer -thumbnailer项目存储库中提供了安装脚本以及Nautilus的.thumbnailer文件。