Image shadow and relative layers position

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Image shadow and relative layers position

Post by spok »

I have an image for which I add a shadow.
Of course adding the shadow will increase the final image dimensions, but I'd like to know the relative position of the original image inside the final image (dx and dy shift). Is this possible ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image shadow and relative layers position

Post by fmw42 »

see http://www.imagemagick.org/script/comma ... php#shadow and http://www.imagemagick.org/Usage/blur/#shadow

The negative of +X+Y should tell you the offsets to your original, if I am not mistaken
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Image shadow and relative layers position

Post by spok »

Thanks but it not what I'm looking for.
For instance you can specify an offset of 10,10 which makes the shadow looks at right bottom.
However, depending on the sigma value (the blur effect) the dimensions of the shadow layer may include completely the original image layer because the blur makes the shadow extents in all directions.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image shadow and relative layers position

Post by fmw42 »

Only other suggestion is to do a compare of the original image with the larger shadowed image and it will tell you the offset.

see
http://www.imagemagick.org/script/compare.php
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076

In the latter, with current versions of IM, one must add -subimage-search.
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Image shadow and relative layers position

Post by spok »

Well may be I should explain more precisely what I want to do. May be there is another solution to do it.
After adding the shadow to the image, I'd like to extend the canvas of the resulted image, keeping the initial image centered in the canvas.

If I just do the extent after the shadow, then the whole image (initial+shadow) will be centered but the initial image will not.

That's why I need the offset between the image layer and the shadow layer, so I can extend the canevas with such values to have the initial picture centered in the canvas.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image shadow and relative layers position

Post by fmw42 »

spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Image shadow and relative layers position

Post by spok »

Thank you !
Post Reply