Auto Thumnailer

Post your How to's here


Auto Thumnailer

Postby TheeMahn » Tue Oct 16, 2007 8:49 am

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
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer

Return to How To's (Do not post questions please)

Who is online

Users browsing this forum: No registered users and 0 guests

cron