annotate jpeg-exif-thumbnailer @ 0:92c70579720e default tip

Initial commit
author Brad Greco <brad@bgreco.net>
date Wed, 13 Jan 2021 19:25:09 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
1 #!/bin/bash
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
2
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
3 # Fast GNOME thumbnailer for JPEG files that uses the embedded EXIF thumbnail
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
4 # from the source file, if present. Greatly speeds up thumbnail generation when
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
5 # browsing a folder of images shared over a network.
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
6 #
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
7 # Usage:
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
8 # jpeg-exif-thumbnailer [size] [source] [destination]
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
9
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
10 set -e
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
11
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
12 # Transform the input file URI (for example, file://... or smb://...) into its
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
13 # locally mounted path.
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
14 input_path=$(gio info "$2" | grep "^local path:" | cut -d ' ' -f 3-)
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
15
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
16 # Use exiftool to extract the embedded preview image.
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
17 exiftool -a -b -W! "$3" -preview:all "$input_path"
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
18
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
19 if [ -s "$3" ]; then
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
20 # If the extraction succeeded, convert the extracted image to the requested
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
21 # format based on the requested file extension, and resize it to the
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
22 # requested size. Since Nautilus requires PNG files, the mogrify command
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
23 # is required even if -resize is not specified.
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
24 mogrify -resize $1x$1 "$3"
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
25 else
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
26 # If the extraction failed, fall back to the default system thumbnailer.
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
27 /usr/bin/gdk-pixbuf-thumbnailer -s "$1" "$2" "$3"
92c70579720e Initial commit
Brad Greco <brad@bgreco.net>
parents:
diff changeset
28 fi