Created
October 10, 2012 14:56
-
-
Save KhasMek/3866143 to your computer and use it in GitHub Desktop.
not another image manipulation script. xD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Image template creator and thumbnail maker. | |
# | |
# USAGE: ./make_lazy $CUSTOM_TITLE_NAME | |
# If CUSTOM_TITLE_NAME is blank, it will use the actual filename | |
# (with underscores and all). | |
# Currently supported formats are .png and .jpg. | |
# | |
# In addition to most normal linux apps, this script will | |
# require the ImageMagick suit for thumbnail creation. | |
# You can find it here http://www.imagemagick.org/script/index.php | |
# first, check to see if we will use a custom name for the title. | |
if [ ! "$1" ]; then | |
echo "Custom title name not defined." | |
echo "Using actual filename instead." | |
fi | |
# nuke blank spaces | |
rename 'y/ /_/' * | |
# make all folders and filenames lowercase | |
# first, rename all folders (lazy kang from another one of my scripts) | |
for f in `find . -depth ! -name CVS -type d`; do | |
g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` | |
if [ "xxx$f" != "xxx$g" ]; then | |
echo "Renaming folder $f" | |
mv -f "$f" "$g" | |
fi | |
done | |
# now, rename all files | |
for f in `find . ! -type d`; do | |
g=`dirname "$f"`/`basename "$f" | tr '[A-Z]' '[a-z]'` | |
if [ "xxx$f" != "xxx$g" ]; then | |
echo "Renaming file $f" | |
mv -f "$f" "$g" | |
fi | |
done | |
# make the html and paste into the output file. | |
ls *.png *.jpg | while read line; do | |
if [ ! "$1" ]; then | |
name=`echo $line | cut -f1 -d "."` | |
else | |
name="$1" | |
fi | |
extension=`echo $line | cut -f2 -d "."` | |
filename=`echo $line | cut -f1 -d "."` | |
(cat << EOF) >> output.html | |
<a href="imgs/space/$line" class="thumb_link"><span class="selected"></span><img src="imgs/space/${filename}_thumb.$extension" title="$name" alt="$name" class="thumb" /></a> | |
EOF | |
done | |
mkdir .thumbs | |
find . ! -name '*.html' ! -name 'khas_is_a_slacker.sh' ! -name '.thumbs' | xargs -i cp {} .thumbs | |
cd .thumbs | |
mogrify -resize 200x200 *.* | |
# add the _small suffix | |
ls | while read line; do | |
extension=`echo $line | cut -f2 -d "."` | |
filename=`echo $line | cut -f1 -d "."` | |
mv $line ../"$filename"_thumb.$extension | |
done | |
# cleanup | |
cd .. | |
rm -rf .thumbs | |
echo "conversion complete..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment