Вопрос :
Файловый менеджер Ubuntu, Nautilus
, поставляется с широкой поддержкой предварительного просмотра файлов. Эти миниатюры обрабатываются вспомогательными программами, называемыми thumbnailers.
Количество миниатюр, которые поставляются с предустановленной Ubuntu, ограничено, и поэтому некоторые более экзотические типы файлов не отображаются по умолчанию.
Какие дополнительные миниатюры можно установить, чтобы активировать предварительный просмотр в этих случаях?
Соответствующие вопросы и ответы :
Как я могу дать Наутилусу команду предварительно генерировать эскизы?
Не стесняйтесь вносить свой вклад в этот список, редактируя вики-ответ сообщества. Если вы сделаете это, пожалуйста, следуйте указаниям в этого Мета-обсуждения и используйте существующий шаблон, чтобы сохранить ответ согласованным.
Thumbnailers a Repositories a PPAs
Eng Zuel vun Thumbnailers si virverpackt a kënnen einfach aus dem Software Center oder der Kommandozeil installéiert ginn. Dës Thumbnailers erfuerderen keng zousätzlech Konfiguratioun a solle funktionnéieren direkt nodeems de Nautilus nei gestart gouf. Dir kënnt dat maache mat:
nautilus -q
Liest w.e.g. dës Froen & Wéi liesen ier Dir eppes vun engem PPA installéiert:
Wat sinn PPAen a wéi benotze ech se?
Sinn PPA sécher fir mäi System bäizefügen a wat sinn e puer roude Fändelen "fir opzepassen?
Benotzerdefinéiert Miniatur Scripten op Ubuntu 11.04 a méi héich
Benotzerdefinéiert Miniaturen déi net an de Repositioune verfügbar sinn, musse manuell installéiert ginn. Dëst sinn d'Schrëtt déi Dir maache musst fir se z'installéieren:
Kuckt ob am Skript keng Ofhängegkeeten opgezielt sinn. Wa jo, installéiert se als éischt.
Luet de Skript erof a maacht et ausführbar mat chmod a + x Filethumbnailer
oder iwwer Nautilus
Designéiert en Dossier an Ärem Dateisystem fir all zukünfteg Miniaturen an réckelt de Skript drop, z
mkdir $ HOME / .scripts / thumbnailers && mv filethumbnailer $ HOME / .scripts / thumbnailers
Als nächst musst Dir Äert Skript mat Nautilus registréieren. Fir dëst ze maachen en Thumbnailer Eintrag an / usr / share / thumbnailers
. D'Entrée soll dem Benennungsschema foo.thumbnailer
wou foo
en Ausdrock vun Ärer Wiel ass (hei Datei
):
gksudo gedit /usr/share/thumbnailers/file.thumbnailer
D'Vignette Spezifikatioune befollegen dëst Schema :
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/file.thumbnailer %i %o %s
MimeType=application/file;
Den Exec
Entrée weist op Äert Thumbnailer Skript wärend de MimeType
Feld déi relatéiert MimeTypes bezeechent. Méiglech Variabelen sinn:
%i Input file path
%u Input file URI
%o Output file path
%s Thumbnail size (vertical)
D'Spezifikatioune an d'Variabelen variéiere mat all Skript. Kopéiert a pecht den Inhalt vun der jeweileger Textbox einfach an d'Datei a späichert se.
D'Thumbnailere solle funktionnéieren nodeems se Nautilus neu gestart hunn ( nautilus -q
).
Benotzerdefinéiert Miniatur Scripten op Ubuntu 11.04 an drënner
Fréier Versioune vun Ubuntu vertrauen op GConf fir Thumbnailer Associatiounen. Kuckt hei fir méi Informatioun.
Quellen :
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 Dateien
Iwwersiicht
Beschreiwung : Mat dësem Skript kritt Dir Thumbnails vun Äre chm Dateien am Nautilus Dateemanager. De Skript benotzt dat gréisste Bild vun d'Homepage vun der chm Datei fir d'Vignette ze generéieren, normalerweis dës wäert e Bild vun der Frontdeckel sinn.
Schëpfer : monraaf ( http://ubuntuforums.org/showthread.php?t=1159569 )
Ofhängegkeeten :
sudo apt-get install python-beautifulsoup python-chm imagemagick
Thumbnailer Entrée
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/chmthumbnailer %i %o %s
MimeType=application/vnd.ms-htmlhelp;application/x-chm;
Skript
#!/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 Dateien
Iwwersiicht
Beschreiwung : epub-Thumbnailer ass en einfacht Skript dat probéiert en Deckel an enger Epub Datei ze fannen an e Miniatur fir en ze kreéieren.
Schëpfer : Mariano Simone ( https://github.com/marianosimone/epub-thumbnailer )
Ofhängegkeeten : keen opgezielt, huet direkt funktionnéiert
Thumbnailer Entry
[Thumbnailer Entry]
Exec=$HOME/.scripts/thumbnailers/epubthumbnailer %i %o %s
MimeType=application/epub+zip;
Skript
#!/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 Dateien
Iwwersiicht
Beschreiwung : gnome-exe-thumbnailer ass en Thumbnailer fir Gnome deen Windows .exe Dateien eng Ikon gëtt op Basis vun hirem agebettene Symbol an e generesche Symbol "Wäiprogramm". Wann de Programm normal ausféiert Permissiounen, da gëtt de Standard agebettene Symbol gewisen. Dëst Thumbnailer gëtt och e Thumbnail Symbol fir .jar, .py, an ähnlech ausführbar Programmer.
Disponibilitéit : offiziell Repositories
Installatioun
sudo apt-get install gnome-exe-thumbnailer
ODP / ODS / ODT an aner LibreOffice an Open Office Dateien
Iwwersiicht
Beschreiwung: ooo-thumbnailer is a LibreOffice , OpenOffice.org a Microsoft Office Dokument Thumbnailer dee ka vun Nautilus benotzt ginn fir maacht Miniaturen fir Är Dokumenter, Tabellen, Presentatiounen an Zeechnungen.
Disponibilitéit : Entwéckler PPA (rezentste Versioun déi kompatibel mat LibreOffice an Ubuntu 12.04 a méi héich ass)
Installatioun
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
для Nautilus доступны в репозитории проекта icns-thumbnailer