# HG changeset patch # User Brad Greco # Date 1610583909 18000 # Node ID 92c70579720ebc38f7acee0e5e65cefd3543f882 Initial commit diff -r 000000000000 -r 92c70579720e LICENSE --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,7 @@ +Copyright 2021 Brad Greco + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -r 000000000000 -r 92c70579720e README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,26 @@ +GNOME JPEG EXIF Thumbnailer +=========================== +Fast GNOME thumbnailer for JPEG files that uses the embedded EXIF thumbnail from +the source file, if present. Greatly speeds up thumbnail generation when +browsing a folder of images shared over a network. + +Installation +------------ +1. Install `exiftool` and `libimage-exiftool-perl` using your package manager. +2. Execute `./install` which automatically runs the steps below. + +Manual Installation +------------------- +1. Copy the `jpeg-exif-thumbnailer` script to `/usr/bin/` . +2. Copy the `jpeg-exif.thumbnailer` definition to `/usr/share/thumbnailers` . +3. Edit `/usr/share/thumbnailers/gdk-pixbuf-thumbnailer.thumbnailer` and remove + `image/disabled-jpeg` from the list of MIME types. + +Uninstallation +-------------- +Execute `./uninstall` which automatically reverts the steps above. + +Copyright +--------- +Copyright 2021 Brad Greco +https://www.bgreco.net/jpeg-exif-thumbnailer diff -r 000000000000 -r 92c70579720e install --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/install Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e + +cwd=$(dirname "$0") + +if [ $EUID -ne 0 ]; then + echo "This script must be run with root privileges." + exit 1 +fi + +if ! which mogrify > /dev/null 2>&1; then + echo "Please install imagemagick first" + exit 1 +fi + +if ! which exiftool > /dev/null 2>&1; then + echo "Please install libimage-exiftool-perl first" + exit 1 +fi + +cp "$cwd/jpeg-exif-thumbnailer" /usr/bin/ +chmod +x /usr/bin/jpeg-exif-thumbnailer +cp "$cwd/jpeg-exif.thumbnailer" /usr/share/thumbnailers/ +grep -l --exclude=jpeg-exif.thumbnailer image/jpeg /usr/share/thumbnailers/*.thumbnailer | xargs --no-run-if-empty sed -i 's|image/jpeg|image/disabled-jpeg|g' diff -r 000000000000 -r 92c70579720e jpeg-exif-thumbnailer --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jpeg-exif-thumbnailer Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,28 @@ +#!/bin/bash + +# Fast GNOME thumbnailer for JPEG files that uses the embedded EXIF thumbnail +# from the source file, if present. Greatly speeds up thumbnail generation when +# browsing a folder of images shared over a network. +# +# Usage: +# jpeg-exif-thumbnailer [size] [source] [destination] + +set -e + +# Transform the input file URI (for example, file://... or smb://...) into its +# locally mounted path. +input_path=$(gio info "$2" | grep "^local path:" | cut -d ' ' -f 3-) + +# Use exiftool to extract the embedded preview image. +exiftool -a -b -W! "$3" -preview:all "$input_path" + +if [ -s "$3" ]; then + # If the extraction succeeded, convert the extracted image to the requested + # format based on the requested file extension, and resize it to the + # requested size. Since Nautilus requires PNG files, the mogrify command + # is required even if -resize is not specified. + mogrify -resize $1x$1 "$3" +else + # If the extraction failed, fall back to the default system thumbnailer. + /usr/bin/gdk-pixbuf-thumbnailer -s "$1" "$2" "$3" +fi diff -r 000000000000 -r 92c70579720e jpeg-exif.thumbnailer --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jpeg-exif.thumbnailer Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,4 @@ +[Thumbnailer Entry] +TryExec=/usr/bin/jpeg-exif-thumbnailer +Exec=/usr/bin/jpeg-exif-thumbnailer %s %u %o +MimeType=image/jpeg; diff -r 000000000000 -r 92c70579720e uninstall --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/uninstall Wed Jan 13 19:25:09 2021 -0500 @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [ $EUID -ne 0 ]; then + echo "This script must be run with root privileges." + exit 1 +fi + +rm -f /usr/bin/jpeg-exif-thumbnailer +rm -f /usr/share/thumbnailers/jpeg-exif.thumbnailer +grep -l image/disabled-jpeg /usr/share/thumbnailers/*.thumbnailer | xargs --no-run-if-empty sed -i 's|image/disabled-jpeg|image/jpeg|g'