4 ## @brief Resize an image to a specified value.
11 current_dir=$(dirname "$(readlink -f "$0")")
13 if ! command -v yad > /dev/null
15 zenity --window-icon=/usr/local/share/pixmaps/geeqie.png --width=400 --info --title "Geeqie Resize" --text="yad and ImageMagick are required\n\nyad is not installed"
19 if ! command -v convert > /dev/null
21 zenity --window-icon=/usr/local/share/pixmaps/geeqie.png --width=400 --info --title "Geeqie Resize" --text="yad and ImageMagick are required\n\nImageMagick is not installed"
27 yad --window-icon=/usr/local/share/pixmaps/geeqie.png --geometry=400 --image dialog-warning --title "Geeqie Resize" --button=gtk-ok:0 --text "\nNo input file was given."
31 basefile=$(basename "$1")
35 default_filename=$(printf %s "/tmp/$base-resized.$ext")
36 if [ -f "$default_filename" ]
41 default_filename=$(printf %s%d%s "/tmp/$base-resized-" "$i" ".$ext")
42 if [ -f "$default_filename" ]
52 selection=$(yad --window-icon=/usr/local/share/pixmaps/geeqie.png \
55 --button=gtk-help:"$current_dir"/resize-help.sh \
56 --button=gtk-cancel:1 \
58 --text="<b>Reduce image size:</b>\n" \
60 --field="Required size kB":NUM '100!1..100000!1!' \
61 --field="Tolerance %":NUM '10!1..100!1!' \
62 --field="Max. iterations":NUM '20!1..100!1!' \
63 --field="Copy if unchanged":CHK 'FALSE' \
64 --field="Strip metadata":CHK 'TRUE' \
65 --field="Show computation":CHK 'FALSE' \
66 --field="Open output file in Geeqie":CHK 'FALSE' \
68 --field="Output file":SFL \
69 --field="Default: $default_filename":LBL )
71 if [ -z "$selection" ]
76 size=$(printf %s "$selection" | cut --delimiter="|" --fields=1 -)
77 tolerance=$(printf %s "$selection" | cut --delimiter="|" --fields=2 -)
78 iterations=$(printf %s "$selection" | cut --delimiter="|" --fields=3 -)
79 copy_unchanged=$(printf %s "$selection" | cut --delimiter="|" --fields=4 -)
80 strip_metadata=$(printf %s "$selection" | cut --delimiter="|" --fields=5 -)
81 show_computation=$(printf %s "$selection" | cut --delimiter="|" --fields=6 -)
82 open_geeqie=$(printf %s "$selection" | cut --delimiter="|" --fields=7 -)
83 file=$(printf %s "$selection" | cut --delimiter="|" --fields=9 -)
87 new_filename="$default_filename"
91 if ! yad --window-icon=/usr/local/share/pixmaps/geeqie.png --geometry=300 --image dialog-warning --title "Geeqie Resize" --text "\nOutput file already exists.\nOverwrite?"
99 if [ "$copy_unchanged" = "FALSE" ]
106 if [ "$strip_metadata" = "FALSE" ]
113 tmp_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
115 yad --window-icon=/usr/local/share/pixmaps/geeqie.png --geometry=300 --image dialog-information --title "Geeqie Resize" --button=OK:0 --text "Running Downsize...." &
118 result=$("$current_dir"/downsize -s "$size" -t "$tolerance" -m "$iterations" -c "$copy" -S "$strip" "$1" "$new_filename" > "$tmp_file" 2>/dev/null)
125 yad --window-icon=/usr/local/share/pixmaps/geeqie.png --geometry=400 --image dialog-warning --title "Geeqie Resize" --button=gtk-ok:0 --text "Downsize failed.\n\nIf the filetype is not supported by Downsize,\ntry the Export plugin to get a jpeg.\n\nDownsize error message:\n$result"
131 if [ "$open_geeqie" = "TRUE" ]
133 geeqie --remote "$new_filename"
137 if [ "$show_computation" = "TRUE" ]
139 yad --window-icon=/usr/local/share/pixmaps/geeqie.png --title "Geeqie Resize computation" --text="$new_filename\n\n$(cat "$tmp_file")" --button=gtk-ok:0