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 » 2011-12-11T11:41:14-07:00

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: 25270
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 » 2011-12-11T11:49:44-07:00

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 » 2011-12-11T12:50:24-07:00

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: 25270
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 » 2011-12-11T14:10:01-07:00

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 » 2011-12-11T14:49:16-07:00

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: 25270
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 » 2011-12-11T15:24:17-07:00


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

Re: Image shadow and relative layers position

Post by spok » 2011-12-11T16:28:09-07:00

Thank you !

Post Reply