Page 1 of 1

blurred shadow and edges of image

Posted: 2012-10-27T17:52:07-07:00
by javismiles
hi :)
when i perform a quite blurred drop shadow on a text (with something like -shadow 100x5+2+2 ) and i produce a PNG of it,
im having the problem that the drop shadow that gradually fades out abruptly ends on the edges of the image,
how can i somehow extend the edges of the image to make sure all of the drop shadow is taken into consideration?
thanks so very much
Jav

Re: blurred shadow and edges of image

Posted: 2012-10-27T17:53:57-07:00
by javismiles
the shadow is applied in my command in this way

$command =$this -> config['magic'].' -background none -fill "'.$thecolor.'" -font '.$font_selection.' -pointsize '.($thesize).' -gravity '.$thealign.' label:"'.$thetext.'" \( -clone 0 -background black -shadow "'.$shadowvalue.'" \) -compose DstOver -composite -compose Over -rotate '.$theangle.' '.$target_image.'';

and the problem is that when the shadow under the text is not very tight, when its quite blurred, which i need, then it abruptly ends against the edges of the image instead of fading out slowly,

there must be a way to automatically account for that shadow to adapt the size of the output image? or any other solution?

thank u so much
Jav

Re: blurred shadow and edges of image

Posted: 2012-10-27T19:45:17-07:00
by fmw42
Use -extend or -border to make the input image larger by supplying a background that is the same color as the edges of the image. I assume you have some constant background in your image upon which you have placed the text. Make it bigger by at least as much as 3x the shadow sigma value. You can make it bigger if you want and then afterwards you can use -trim to remove the excess border.

see
http://www.imagemagick.org/Usage/crop/#border
http://www.imagemagick.org/Usage/crop/#extent
http://www.imagemagick.org/Usage/crop/#trim

Re: blurred shadow and edges of image

Posted: 2012-12-04T18:59:54-07:00
by anthony
Don't use -composite for -shadow imagees! Composite may not expand the image to account for the space of the shadow, thus it is getting clipped.

Also composite is a low level operator that does not use a 'layer offset' that shadow produces. Proper layering commands feeds the internal 'composite' operator with the correct layering offsets. As such your shadow image is probably not even positioned right (according to the arguments given to the -shadow operator)

This is why -layers merge is used, it expands the 'canvas' used to layer both images (foreground and shadow) so that the canvas contains both images in total, at the offsets specified in the images, even if the final image needs a negative offset to align the images correctly (the offset is typically removed and ignored in final result using +repage)

See IM Examples shadowing...
http://www.imagemagick.org/Usage/blur/#shadow