-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathimagemagick-zenity
82 lines (73 loc) · 2.97 KB
/
imagemagick-zenity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Author: Rosen Aleksandrov
# E-Mail: [email protected]
# IRC: irc.freenode.net/#calculate irc.politeia.in/#bulgaria
# Dependencies: zenity imagemagick
# License: GPLv3
gui="zenity"
converter="mogrify"
title="imagemagick-zenity"
$gui --width 500 --question --title="$title" --text "Welcome to imagemagick-zenity!" --ok-label="Start" --cancel-label="Quit"
case $? in
0)
echo $welcome ;;
1)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
255)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
esac
IFS=$'\n' image=( `$gui --file-selection --multiple --separator=$'\n' --filename=$HOME/ --file-filter='Image Files (jpg,png,bmp,tiff,pdf,djvu) | *.jpg *.png *.bmp *.tiff *.pdf *.djvu' --file-filter='All files | *' --title="Select an image files"` )
case $? in
0)
echo $image ;;
1)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
255)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
esac
outformat=`$gui --title="Format Selector" --list --radiolist --width=400 --height=300 --column="" --column="Format" TRUE "jpg" FALSE "png" FALSE "bmp" FALSE "tiff" FALSE "pdf" FALSE "djvu" --text "Select output image format."`
case $? in
0)
echo $outformat ;;
1)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
255)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
esac
scale=`$gui --scale --text="Quality level" --value=85`
case $? in
0)
echo $scale ;;
1)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
255)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
esac
resolution=`$gui --title="Resolution Selector" --list --radiolist --width=400 --height=300 --column="" --column="Resolution" FALSE "640x480" FALSE "800x600" FALSE "1024x768" FALSE "1280x1024" TRUE "1680x1050" FALSE "1920x1080" --text "Select image resolution"`
case $? in
0)
echo $resolution ;;
1)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
255)
$gui --warning --title="$title" --text "Program will close when press OK" ; exit 0 ;;
esac
IFS=$'\n' outpath=`$gui --file-selection --separator=$'\n' --filename=$HOME/ --directory --title="Select where to save converted images."`
case $? in
0)
echo $outpath ;;
1)
echo "Calcel Pressed!" ;;
255)
echo "Window Closed!" ;;
esac
step=$((100/${#image[@]}))
pos=0
(
for i in ${image[@]}; do
echo "# Current file:\n$i"
$converter -path $outpath -format $outformat -quality $scale -scale $resolution "$i"
pos=$(($pos+1))
echo $(($step*$pos))
done
) | $gui --progress --percentage=0 --no-cancel --auto-close --title="$title"