Page 1 of 1
Applying 3d shadow but image source changes
Posted: 2011-07-25T01:23:19-07:00
by jdespatis
Hello,
I'd like to create an icon for google maps, as a result I need to add a shadow to an image.
Thanks to this post:
viewtopic.php?f=1&t=13639
Based on IM example:
http://www.imagemagick.org/Usage/distorts/#shadow3d
I can create such a shadow, But with an image with a slight border like this one:
I get this result, which is crappy (the border is crappy):
Here is my full command:
Code: Select all
convert input.png -flip +distort SRT '0,0 1,-1 0' \( +clone -background none -shadow 60x5+0+0 -virtual-pixel Transparent +distort Affine '0,0 0,0 100,0 100,0 0,100 -100,50' \) +swap -background none -layers merge -fuzz 2% -trim +repage output.png
=> Any idea how to get a clean image ?
Re: Applying 3d shadow but image source changes
Posted: 2011-07-25T06:44:28-07:00
by jdespatis
Oups image have been moved,
I've created them again for the post to be valid
If anyone has an idea...
Thanks
Re: Applying 3d shadow but image source changes
Posted: 2011-07-25T10:38:51-07:00
by fmw42
just chop a few pixels off the bottom of the shadow before merging or even afterwards. see -chop
http://www.imagemagick.org/Usage/crop/#chop
Then floodfill the lower left corner with transparency.
convert output.png -gravity south -chop 0x3 \
-fuzz 50% -fill none -draw "matte 0,60 floodfill" output_new.png
or if you need to preserve the image size
convert \( output.png -gravity south -chop 0x3 \
-fuzz 50% -fill none -draw "matte 0,60 floodfill" \) \
\( -clone 0 -alpha off -fill black -colorize 100% -transparent black \) \
+swap -gravity northwest -compose over -composite \
output_new2.png
Re: Applying 3d shadow but image source changes
Posted: 2011-07-25T12:51:43-07:00
by fmw42
see also the topic
viewtopic.php?f=1&t=13639
and the link in it
http://www.cycloloco.com/shadowmaker/
or try a little offset
convert input.png -flip +distort SRT '0,0 1,-1 0' \
\( +clone -background black -shadow 60x5+0+0 -virtual-pixel Transparent \
+distort Affine '0,0 3,-5 100,0 105,-3 0,100 -100,50' \) \
+swap -background none -layers merge -fuzz 2% -trim +repage \
output_new3.png
Re: Applying 3d shadow but image source changes
Posted: 2011-07-25T17:24:00-07:00
by anthony
This looks remarkably like a image that had a nice shaped color border, but was badly convered to a alpha shape. Now that bad convorsion needs to be fixed to clean up the border.
As it is the border that is crappy I would first remove it. A morphology erode of just the alpha channel will do the trick.
Now you can flatten it on white (recoloring those pixels) and restore the anti-aliasing of the original shape.
Code: Select all
convert input.png -virtual-pixel transparent \
\( +clone -channel A -morphology erode square +channel \
-background white -flatten \) \
-compose In -composite edge_cleaned.png
Now if you do you shadows you will not have the crappy border messing things up.