possible bug with -geometry -composite with IM 6.4.3-5

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug with -geometry -composite with IM 6.4.3-5

Post by fmw42 »

IM 6.4.3-5 Q16 Mac OSX Tiger.

The documentation for -geometry says:

"If the x is negative, the offset is measured leftward from the right edge of the screen to the right edge of the image being displayed. Similarly, negative y is measured between the bottom edges."

Perhaps I am misunderstanding this, but as I read it, if I composite a small image on a larger image with negative offsets, then the composite should be from the bottom right inward.

But neither the following seem to do that. The rose image ends up shifted up and to left of the top left corner of the white background and thus slightly cropped off.

convert \( -size 100x100 xc:white \) rose: -geometry -10-10 -composite rose_white.png

and same for

convert \( -size 100x100 xc:white \) rose: -geometry 70x46-10-10 -composite rose_white.png

Am I misunderstanding something here or is this a bug or just confusing (at least to me) documentation?

If the result is correct, is there any way to combine -gravity and -geometry to do something like:

... -gravity southeast -geometry -10-10 ...

to get the composite inward 10 pixels in each of x and y from the bottom right corner? I tried that but all I got was the rose in the bottom right corner.

AH HA! Actually using positive offsets seems to work! So this works to offset the rose inward from the bottom right.

convert \( -size 100x100 xc:white \) rose: -gravity southeast -geometry +10+10 -composite rose_white.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug with -geometry -composite with IM 6.4.3-5

Post by anthony »

That is correct. The -geometry offset is used to control absolute positioning of image according to -gravity in a number of composite operators (not all). It specifies the offset from the edge, inward!

NOTE some composite operators use geometry and gravity
(-composite for example) while others use the virtual canvas offset (-page or -repage) whcih is NOT gravity effected, and will always be positioned relative to the canvas origin (EG: image layering operators like -flatten and -layer merge)

Only ONE composite operator will handle BOTH -layer composite for merging multiple sequences of images. The -gravity effected -geometry is used to set and offset the whole sequence using the first images virtual canvas size, while the virtual canvas offset is used to position each individual image within that global -geometry offset position.

That is -geometry positions the canvas origin of the two image layer sequences (globally) while virtual canvas offset is relative position (individually) within a image layer sequence.

I do try to explain this within Alpha Compositing section in IM Examples
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug with -geometry -composite with IM 6.4.3-5

Post by fmw42 »

anthony wrote:That is correct. The -geometry offset is used to control absolute positioning of image according to -gravity in a number of composite operators (not all). It specifies the offset from the edge, inward!

NOTE some composite operators use geometry and gravity
(-composite for example) ....

Thanks Anthony, I see that now at http://www.imagemagick.org/Usage/annota ... ge_gravity

So the bottom line is the -geometry documentation on the options page seems confusing at least to me.
Post Reply