6 ## Requires ImageMagick and exiftool
7 ## Crops the image to the size set by the Draw Rectangle menu item
12 tmpdir=$(mktemp --tmpdir --directory geeqie_crop_image_XXXXXX)
14 list=$(exiv2 -pp "$1")
17 readarray -t split_list <<<"$list"
19 array_length="${#split_list[@]}"
20 exiv2 --location "$tmpdir" -ep"$array_length" "$1"
22 src_filename=$(ls "$tmpdir/")
23 filename="${src_filename%.*}"
24 extension="${src_filename##*.}"
25 rotation=$(exiftool -Orientation -n "$1" | cut -d':' -f2 | xargs)
26 convert "$tmpdir/$src_filename" -crop "$2" "$tmpdir/$filename-crop.$extension"
28 exiftool -Orientation=$rotation -n "$tmpdir/$filename-crop.$extension"
30 rm "$tmpdir/$src_filename"
32 geeqie --remote view:"$tmpdir/$filename-crop.$extension"
43 tmpdir=$(mktemp --tmpdir --directory geeqie_crop_image_XXXXXX)
45 src_filename=$(basename -- "$1")
46 filename="${src_filename%.*}"
47 extension="${src_filename##*.}"
48 convert "$1" -crop "$2" "$tmpdir/$filename-crop.$extension"
51 zenity --error --title="$title" --text="Cannot process this file format" --width="$width" --window-icon="$window_icon"
53 geeqie --remote view:"$tmpdir/$filename-crop.$extension"
57 export window_icon="/usr/local/share/pixmaps/geeqie.png"
58 export title="Geeqie crop image"
61 if [ -x "$(command -v convert)" ]
63 if [ -x "$(command -v exiftool)" ]
66 coords=$(geeqie --remote --get-rectangle)
70 zenity --error --title="$title" --text="Rectangle coordinates have not been set" --width="$width" --window-icon="$window_icon" 2>/dev/null
74 filename=$(basename -- "$1")
75 extension="${filename##*.}"
77 if [ "${extension,,}" = "jpeg" ]
80 process_plain "$1" $coords
81 elif [ "${extension,,}" = "jpg" ]
84 process_plain "$1" $coords
85 elif [ "${extension,,}" = "png" ]
88 process_plain "$1" $coords
89 elif [ "${extension,,}" = "tif" ]
92 process_plain "$1" $coords
93 elif [ "${extension,,}" = "tiff" ]
96 process_plain "$1" $coords
98 process_raw "$1" $coords
101 process_plain "$1" $coords
105 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
109 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