Bash Script to resize images

One of my firends wanted this , so i explained him stepwise how to do it , then thought why not a script , here it is :

#! /bin/bash

ZENITY=/usr/bin/zenity

if hash zenity 2>/dev/null; then

if hash mogrify 2>/dev/null; then

loc=$(${ZENITY} --file-selection --title="Select a File" --directory)

cd $loc

pwd

mkdir resized

cp $loc/* $loc/rz/

cd rz

size=$(zenity --title "Give the required resize value" --entry --text "Resize value")

type=$(zenity --title "Give the file type you want to resize " --entry --text "File type")

mogrify -resize $size! *.$type | ( zenity --width=400 --height=100 --progress --title="Please wait " --text="......." --percentage=0)

zenity --info --text="Operation completed"

else

echo "Installing the dependcies"

sudo apt-get install imagemagick

sudo apt-get install zenity

exit 0;

fi

fi

Share this