6 ## Requires ImageMagick and exiftool
7 ## Crops the image to the size set by the Draw Rectangle menu item
12 tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
14 array_length=$(exiv2 -pp "$1" | wc -l)
16 if [ "$array_length" -gt 0 ]
18 # Take last item - should be highest resolution
19 exiv2 --location "$tmpdir" -ep"$array_length" "$1"
21 src_filename=$(ls "$tmpdir/")
22 filename="${src_filename%.*}"
23 extension="${src_filename##*.}"
24 rotation=$(exiftool -Orientation -n "$1" | cut -d':' -f2 | xargs)
25 convert "$tmpdir/$src_filename" -crop "$2" "$tmpdir/$filename-crop.$extension"
27 exiftool -Orientation="$rotation" -n "$tmpdir/$filename-crop.$extension"
29 rm "$tmpdir/$src_filename"
31 geeqie --remote --view="$tmpdir/$filename-crop.$extension"
42 tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
44 src_filename=$(basename -- "$1")
45 filename="${src_filename%.*}"
46 extension="${src_filename##*.}"
47 convert "$1" -crop "$2" "$tmpdir/$filename-crop.$extension"
50 zenity --error --title="$title" --text="Cannot process this file format" --width="$width" --window-icon="$window_icon"
52 geeqie --remote --view="$tmpdir/$filename-crop.$extension"
56 export window_icon="/usr/local/share/pixmaps/geeqie.png"
57 export title="Geeqie crop image"
60 if [ -x "$(command -v convert)" ]
62 if [ -x "$(command -v exiftool)" ]
65 coords=$(geeqie --remote --get-rectangle)
69 zenity --error --title="$title" --text="Rectangle coordinates have not been set" --width="$width" --window-icon="$window_icon" 2> /dev/null
73 filename=$(basename -- "$1")
74 extension=$(printf '%b' "${filename##*.}" | tr '[:upper:]' '[:lower:]')
75 if [ "${extension}" = "jpeg" ]
77 process_plain "$1" "$coords"
78 elif [ "${extension}" = "jpg" ]
80 process_plain "$1" "$coords"
81 elif [ "${extension}" = "png" ]
83 process_plain "$1" "$coords"
84 elif [ "${extension}" = "tif" ]
86 process_plain "$1" "$coords"
87 elif [ "${extension}" = "tiff" ]
89 process_plain "$1" "$coords"
91 process_raw "$1" "$coords"
94 process_plain "$1" "$coords"
98 zenity --info --title="$title" --width="$width" --height=100 --text="Crop image\n\nexiftool is not installed" --title="$title" --window-icon="$window_icon" 2> /dev/null
102 zenity --info --title="$title" --width="$width" --height=100 --text="Crop image\n\nImageMagick is not installed" --title="$title" --window-icon="$window_icon" 2> /dev/null