I have this cool little snippet that I found, which adds a shadow to an image. (using imageMagick, i think..)
image-shadow () {
out=${1%.*}-shadow.${1#*.}
in=$1
echo "Converted file : $out"
if [ ! -z $2 ] ; then
convert $in -frame $2 $out
in=$out
fi
convert $in \( +clone -background black -shadow 60x5+3+3 \) \
+swap -background transparent -layers merge +repage $out
}
We use:
image-shadow test.png 0x0
to add 0x0 border, and 3x3 shadow, as defined inside the function...
Now, I have *-hd.png images, and *.png images .. And would like to add 3x3 shadows to the *.png and 6x6 to the *-hd.png (obviously, retina graphics..)
1- How can I compare the the image name, and decide
2- How can I pass the shadow size
Thanks!
For 1.: Use find, it is really the Swiss army knife for such jobs:
find '(' -name '*.png' -and -not -name '*-hd.png' ')' -exec image-shadow '{}' 0x0 ';'
Of course, you'll have to save your function as a single shell file instead of a shell function, but this is desirable for code reuse anyway.
For 2.: Use another command line argument, which is referenced in the function as $3.
for f in *.png; do
case "$f" in
*-hd.png) shadow="6x6" ;;
*) shadow="3x3" ;;
esac
image-shadow "$f" $shadow
dona
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.