My final (for now) working version of the Rounded Corners and Drop Shadow script.
Why I wrote it:
I have a few blogs to maintain and people tend to send me FaceBook images that are notmuch more than Thumbnails - sometimes as low as 20KB, usually around 100KB. And they expect them to look great on the blog.
I also take a lot of photos at about 4-5MB size. Often these go on a blog and need to be scaled down.
In both cases running an Unsharp Mask generally makes them bearable at the adjusted size.\
And obviously, I have been applying the round corners and drop shadow in GIMP or batching them in Phatch - neither of which gave me the desired result.
On my Celeron 1.6GHz Gigabyte Brix, 13 jpegs about 4.5MB each were resized to 1024px, unsharped and processed into png files with rounded corners at an average size of 1.5MB each in about 30 seconds with this script.
The size can be changed, the unsharp line can be removed and I also have a copy that applies a gemeric S-Curve to cruddy images.
USAGE (in Linux):
Copy the script into a directory.
Mark the script executable.
Copy some jpg or JPG inages into the same directory.
Click the script.
If the folder is open, and as long as you have 'Show Previews' turned on, you should see a small green 'waiting' sign appear in the folder. If previews are off, it doesn't matter.
After a while the green sign is replaced by a blue Done sign.
Regardless of whether your previews are turned on or off, once the job is complete a large sign should pop up on the desktop when the job is finished.
There's a heap of room for improvement, my BASH skills are pretty primitive and some of the script was simply left over from study tutorials. Some was copied from 'how to' examples on the ImageMagick site. I have several copies set to make different size images.
This is for Linux. Windows or Mac users will need to mess with it.
Code: Select all
#!/bin/bash
# Ross Devitt - An ImageMagick script to add Rounded Corners
# and Drop Shadows to all jpeg images in a folder
#I'm using ImageMagick 6.7.7-10 on Mint 17.3 KDE
#
# Remove previous done message
rm 0done.png
# make WORKING message
convert -background white -fill green -font Arial -pointsize 156 -size 800x800 \
-gravity center label:'WORKING\n \nPlease\nWAIT 2-3 mins..' \
0working.png
# RENAME any JPG to jpg
#!/bin/sh
# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files--does not change the name of directories
# will ask for verification before overwriting an existing file
for x in `ls`
do
if [ ! -f $x ]; then
continue
fi
lc=`echo $x | tr '[A-Z]' '[a-z]'`
if [ $lc != $x ]; then
mv $x $lc
fi
done
mkdir roundcorners
for f in *.jpg
do convert $f -resize 1024 \
\( +clone -alpha extract \
-draw 'fill black polygon 0,0 0,45 45,0 fill white circle 45,45 45,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite -unsharp 10x4+1+0 roundcorners/$f.png
# To add contrast and brightness to dull images insert the following
# between -composite and -unsharp (above) -composite -sigmoidal-contrast 5,35%
done
cd roundcorners
mkdir ../corners-shadows
#Get rid of double extension
for i in *.png
do
mv "$i" "`echo $i | sed 's/.jpg//'`"
done
for f in *.png
do convert $f -page +20+20 -alpha set \
\( +clone -background black -shadow 60x20+20+20 \) +swap \
-background none -mosaic ../corners-shadows/$f.png
done
cd ../corners-shadows
#Get rid of double extension
for i in *.png
do
mv "$i" "`echo $i | sed 's/.png//'`"
done
cd ..
#Clean Up and Remove WORKING message
rm 0working.png
# Message when job is done
convert -background white -fill blue -font Arial -pointsize 88 -size 800x800 \
-gravity center label:'DONE!\nJob is in\nRoundCorners\nand\ncorners-shadows\' \
0done.png
display 0done.png
# End of Program
I'm sharing this as a thank you to the people who have helped me with suggestions over a few years and because I love what ImageMagick has allowed me to do with my graphics...
RossD.