1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash
#
# Copyright 2007 Erlend Davidson <Erlend.Davidson@gmail.com>
# Copyright 2009 David D Lowe <DavidDLowe.flimm@gmail.com>
#
# 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 2 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 Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ooo-thumbnailer
# usage:
# ooo-thumbnailer file outfile size
# example:
# ooo-thumbnailer document.odt thumbnail.png 128
# command line parameters
ifile=$1
ofile=$2
size=$3
test -f ${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs && source ${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs
# documents in the Templates directory are ignored
if [ `dirname "$ifile"` != ${XDG_TEMPLATES_DIR:-$HOME/Templates} ]; then
# use imagemagick if it's installed
# (currently, always the case until GNOME bug #576750 is fixed and
# dependency on imagemagick is removed)
if [ -x /usr/bin/convert ]; then
if [ "$size" == "" ]; then
unzip -p "$ifile" Thumbnails/thumbnail.png | convert - +matte "png:$ofile"
else
unzip -p "$ifile" Thumbnails/thumbnail.png | convert - +matte -scale ${size}x${size} "png:$ofile"
fi
else
cache=${XDG_CACHE_HOME:-$HOME/.cache}
mkdir -p "$cache"
unzip -o "$ifile" Thumbnails/thumbnail.png -d "${cache}"
if [ "$size" == "" ]; then
totem-video-thumbnailer "${cache}/Thumbnails/thumbnail.png" "$ofile"
else
totem-video-thumbnailer "${cache}/Thumbnails/thumbnail.png" "$ofile" -s $size
fi
fi
# add appropriate OpenOffice.org logo if imagemagick is installed
if [ -x /usr/bin/composite ] && [ -e /usr/share/icons/hicolor/32x32/mimetypes/openofficeorg3-oasis-text.png ]; then
estensione=$(expr "$ifile" : '.*\(....\)')
case "$estensione" in
.odt)
composite -gravity SouthEast /usr/share/icons/hicolor/32x32/mimetypes/openofficeorg3-oasis-text.png "$ofile" "$ofile"
;;
.odp)
composite -gravity SouthEast /usr/share/icons/hicolor/32x32/mimetypes/openofficeorg3-oasis-presentation.png "$ofile" "$ofile"
;;
.odg)
composite -gravity SouthEast /usr/share/icons/hicolor/32x32/mimetypes/openofficeorg3-oasis-drawing.png "$ofile" "$ofile"
;;
.ods)
composite -gravity SouthEast /usr/share/icons/hicolor/32x32/mimetypes/openofficeorg3-oasis-spreadsheet.png "$ofile" "$ofile"
;;
esac
fi
fi
|