Page 1 of 1

Auto Thumnailer

PostPosted: Tue Oct 16, 2007 8:49 am
by TheeMahn
I thought I would post a script I just enhanced to help others with the making of thumbnails, I will come back and make this post more elaborate when I have time:

Code: Select all
#!/bin/sh
# Auto Thumbnailer script Via TheeMahn
#
#
# Copyright (c) 2007  Ubuntusoftware Team <http://ubuntusoftware.info>
#
# 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.

# Dialog box to choose thumb's size
SIZE=`zenity --list --title="Choose the thumbnail's size" --radiolist --column="Check" --column="Size" "" "48X48" "" "100X100" "" "320x240" "" "640x480" "" "800x600" "" "1024x768" "Custom" "Custom"`
EXT=`zenity --list --title="Convert to" --radiolist --column="Check" --column="Extention" "" "jpg" "" "png" "" "gif"`

if [ "${SIZE}" == "" ]; then   
zenity --error --text="Size not defined by user.
Please choose a size to use. "
exit 1
fi

# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find -iname "*.jpg" -maxdepth 1 | wc -l`
let "INCREMENT=100/$NUMBER_OF_FILES"

mkdir -p thumbnails

# Creating thumbnails. Specific work on picture should be add there as convert's option
rename 's/\.JPG/\.jpg/' *.JPG
(for i in *.jpg; do
OUTFILE=$(echo $i | sed -e "s/.jpg//")
echo "$PROGRESS";
echo "# Resizing $i";
convert -resize "${SIZE}"  -quality 90 "${i}" thumbnails/"${OUTFILE}.${EXT}"
let "PROGRESS+=$INCREMENT"
done
) | zenity  --progress --title "$Creating thumbnails..." --percentage=0

#process png
# How many files to make the progress bar
PROGRESS=0
NUMBER_OF_FILES=`find -iname "*.png" -maxdepth 1 | wc -l`
let "INCREMENT=100/$NUMBER_OF_FILES"

mkdir -p thumbnails

# Creating thumbnails. Specific work on picture should be add there as convert's option
rename 's/\.PNG/\.png/' *.PNG
(for i in *.png; do
OUTFILE=$(echo $i | sed -e "s/.png//")
echo "$PROGRESS";
echo "# Resizing $i";
convert -resize "${SIZE}"  -'${EXT}' -quality 90 "${i}" thumbnails/"${OUTFILE}.${EXT}"
let "PROGRESS+=$INCREMENT"
done
) | zenity  --progress --title "$Creating thumbnails..." --percentage=0