Page 1 of 1

Image Magick c++ interface: Image::extent ignoring gravity?

Posted: 2014-03-05T08:25:07-07:00
by esok
I want to create an image programmatically, similar to using the command-line "convert -append". I am successfully using the STL append function to get all my images together in the same one, but they were all left-justified. So now I want to center each of the images horizontally. The Image::extent function seems ideal for this, since it will let me give a geometry, a background color, and a gravity. The geometry and background color settings I use are working, but despite changing the gravity to all sorts of other values, the subimage remains at the left in the final image. Am I using the extent() function wrong? Here's a snippet:

image.extent(Magick::Geometry(h_pixels, image.size().height()), Magick::Color("black"), Magick::CenterGravity);

h_pixels is the new width, and I want to keep the original height. I want to have the original image centered within the new extent.

Edit:
I'm using Version: ImageMagick 6.7.5-6 2012-08-11 Q16