#!/bin/bash # Author: Rosen Aleksandrov # E-Mail: sandikata@yandex.ru # 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"