Page 1 of 1

Determining layer offset geometry in Magick++

Posted: 2010-12-13T01:46:08-07:00
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?

Re: Determining layer offset geometry in Magick++

Posted: 2010-12-13T06:38:10-07:00
by magick
Have you tried image.page()? There is also a Magick::Options::page() method.

Re: Determining layer offset geometry in Magick++

Posted: 2010-12-17T19:28:29-07:00
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;
}

Re: Determining layer offset geometry in Magick++

Posted: 2010-12-19T18:03:24-07:00
by anthony
See the discussion about -geometry offsets vs -page offsets in IM Examples, Composition
http://www.imagemagick.org/Usage/compose/#geometry