#!/bin/bash #Author: Copyright Jelle de Jong #Note: Please send me an email if you enhanced this script #Version: 0.0.5 #Date: 10-03-07 / 11-10-07 / 2009-02-26 / 2009-03-23 / 2009-07-06 #System: Ubuntu/Debian GNU/Linux #Information: man convert #Category Thunar scripts (thunar->edit->custom actions) #Name: Convert Image #Description: Create special new image(s) #Command: xfce4-terminal --disable-server --hide-toolbars --execute /usr/share/pct-thunar-scripts/scripts/convert-image %F #Patterns: * #Image Files: True # Did the script work for you? # Yes # Yes, but with some errors # Yes, but I had to change some things # Not at all # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. TEXTDOMAINDIR=/usr/share/locale TEXTDOMAIN=${0##*/} NAME=$"Convert Image" DESCRIPTION=$"Create special new image(s)" cecho() { case "$1" in "black") echo -ne "\E[30m" ;; "red") echo -ne "\E[31m" ;; "green") echo -ne "\E[32m" ;; "yellow") echo -ne "\E[33m" ;; "blue") echo -ne "\E[34m" ;; "magenta") echo -ne "\E[35m" ;; "cyan") echo -ne "\E[36m" ;; *) echo -ne "\E[30m" exit ;; esac echo "$2" "$3" tput sgr0 } cecho "green" $"program:" echo "$0" cecho "green" $"description:" echo "$DESCRIPTION" cecho "green" $"process these file(s):" for I in "$@" do file=${I##*/} cecho "cyan" "$file" done question() { cecho "green" $"choose a option and press enter" echo "[1] 320x240" echo "[2] 640x480" echo "[3] 800x600" echo "[4] 1024x768" echo "[5] 1280x960" echo "[6] 1400x1050" echo $"[7] back and white" echo $"[8] increase with 20%" echo $"[9] decrease with 20%" echo $"[10] process for documentation" echo $"[11] two images to one" echo $"[12] four images to one" echo $"[13] nine images to one" echo $"[14] sixteen images to one" echo $"[15] convert to tiff format" echo $"[16] exit" cecho "green" $"option:" read option } unset option while [ -z "$option" ] do question done #whereis convert if [ ! -e /usr/bin/convert ] then cecho "red" $"imagemagick toolkit not found, installing now" sudo apt-get install imagemagick fi cecho "green" $"enter current working directory:" cecho "cyan" "$PWD" cd "$PWD" for I in "$@" do dirname=${I%/*} file=${I##*/} filename=${I##*/}; filename=${filename%.*} extension=${I##*.} #echo "$dirname" #echo "$file" #echo "$filename" #echo "$extension" #if [[ $I = *.* ]]; then [[ $I = *.tar.gz ]] && ext=tar.gz || ext=${I##*.}; else unset ext; fi; file=${I%${ext+.$ext}} file=${file##*/} dir=${I%$file${ext+.$ext}} #[ $I = *.tar.* ]] && x=${I%.tar.*} ext=${I##$x.} || else unset ... #... fi; ext=${ext+.$ext} file=${I%$ext} file=${file##*/} dir=${I%$file$ext} if [ ! -w "$I" ] then permission="sudo" fi if [ "$option" = "1" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -adaptive-resize 320x240 -verbose "320x240-$filename.$extension" fi if [ "$option" = "2" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 640x480 -verbose "640x480-$filename.$extension" fi if [ "$option" = "3" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 800x600 -verbose "800x600-$filename.$extension" fi if [ "$option" = "4" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 1024x768 -verbose "1024x768-$filename.$extension" fi if [ "$option" = "5" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 1280x960 -verbose "1280x960-$filename.$extension" fi if [ "$option" = "6" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 1400x1050 -verbose "1400x1050-$filename.$extension" fi if [ "$option" = "7" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -type Grayscale -verbose "grayscale-$filename.$extension" fi if [ "$option" = "8" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 120%x120% -verbose "increase-$filename.$extension" fi if [ "$option" = "9" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize 80% -verbose "decrease-$filename.$extension" fi if [ "$option" = "10" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -resize '640x480>' -verbose "documentation-$filename.$extension" fi if [ "$option" = "11" ] || [ "$option" = "12" ] || [ "$option" = "13" ] || [ "$option" = "14" ] then #$permission montage -background none -border 0 -tile 2x2 "${image_query[@]}" -quality 100 -verbose "4in1-image.jpg" #$permission montage -tile 2x2 "$file" -quality 100 -verbose "4in1-$filename.$extension" #convert 1.png 2.png +append \( 3.png 4.png +append \) -append out.png #http://www.imagemagick.org/Usage/layers/#append echo $"adding $filename to image query" image_query+=("$file") fi if [ "$option" = "15" ] then cecho "green" $"staring convert command, please standby" $permission convert "$file" -quality 100 -verbose "$filename.TIFF" fi if [ "$option" = "16" ] then exit 0 fi cecho "green" $"completed" cecho "cyan" "---------------" done if [ -n "$image_query" ] then if [ "$option" = "11" ] then cecho "green" $"staring convert command, please standby" $permission convert -quality 100 -verbose "${image_query[0]}" +append \( "${image_query[1]}" +append \) -append 2in1-image.jpg fi if [ "$option" = "12" ] then cecho "green" $"staring convert command, please standby" $permission convert -quality 100 -verbose "${image_query[0]}" "${image_query[1]}" +append \( "${image_query[2]}" "${image_query[3]}" +append \) -append 4in1-image.jpg fi if [ "$option" = "13" ] then cecho "green" $"staring convert command, please standby" $permission convert -quality 100 -verbose "${image_query[0]}" "${image_query[1]}" "${image_query[2]}" +append \( "${image_query[3]}" "${image_query[4]}" "${image_query[5]}" +append \) -append +append \( "${image_query[6]}" "${image_query[7]}" "${image_query[8]}" +append \) -append 9in1-image.jpg fi if [ "$option" = "14" ] then cecho "green" $"staring convert command, please standby" $permission convert -quality 100 -verbose "${image_query[0]}" "${image_query[1]}" "${image_query[2]}" "${image_query[3]}" +append \( "${image_query[4]}" "${image_query[5]}" "${image_query[6]}" "${image_query[7]}" +append \) -append +append \( "${image_query[8]}" "${image_query[9]}" "${image_query[10]}" "${image_query[11]}" +append \) -append +append \( "${image_query[12]}" "${image_query[13]}" "${image_query[14]}" "${image_query[15]}" +append \) -append 16in1-image.jpg fi cecho "green" $"completed" cecho "cyan" "---------------" fi echo -n $"everything completed, are you sure you want to exit [Y/n]? " read input if [ "$input" = "n" ] then exit 0 fi exit 0 ##!/bin/bash #for I #do #if [[ $I = *.* ]] #then [[ $I = *.tar.gz ]] && ext=tar.gz || ext=${I##*.} #else unset ext #fi #ext=${ext+.$ext} #file=${I%$ext} file=${file##*/} #dir=${I%$file$ext} #echo $I #[[ $I = "$dir$file$ext" ]] || echo "oops: $I != $dir$file$ext" #echo dir=$dir file=$file ext=$ext #echo #done