Determining layer offset geometry in Magick++

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
wise0wl

Determining layer offset geometry in Magick++

Post by wise0wl »

Good evening,

I have looked through the examples and scrounged over the IM docs for Magick++ and haven't found a concrete way of determining a particular layers x,y offsets in relation to the background (ie. if background is 1000x1000, layer 1 is 250x250 at +50+20). Command line "identify" is usually able to extract geometry from the image including these variables, but I can't seem to find anything in the IM docs that points me in the right direction besides perhaps using the Magick::Pixels::getPixels() method, but I am not sure how these coordinates might be in relation to the image as a whole, or in relation to only the previous layer.

Thoughts?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Determining layer offset geometry in Magick++

Post by magick »

Have you tried image.page()? There is also a Magick::Options::page() method.
wise0wl

Re: Determining layer offset geometry in Magick++

Post by wise0wl »

Ahhhh nice :) image.page() actually worked perfectly! I guess I didn't quite get from the documentation that it returns a Geometry object.

Just for anybody else that's reading this in the future, I used the following:

int i, c;
list <image> image;
readImages(&image, img_name.c_str());
c = image.size();
for(i=0;i<c;i++)
{
image.pop_front(); // So I don't read the merged image "layer"
std::cout << "x: " << image.front().page().xOff() << "y: " << image.front().page.yOff() << endl;
}
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Determining layer offset geometry in Magick++

Post by anthony »

See the discussion about -geometry offsets vs -page offsets in IM Examples, Composition
http://www.imagemagick.org/Usage/compose/#geometry
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply