Page 1 of 1

Sample from introduction to magick++ fails

Posted: 2014-03-26T09:54:43-07:00
by seth5744
I have just started to try and use Magick++ and tried the example from the introduction under the section " Extracting a region from within an image" The code I tried is:

Code: Select all

#include <Magick++.h>
using namespace Magick;

main(int argc, char**argv)
{
  InitializeMagick(*argv);
  Image source_image("foo.png");
  Image sub_image(source_image);
  sub_image.chop(Geometry(100,100));
  sub_image.crop(Geometry(200,200));
}
The output is:

Code: Select all

terminate called after throwing an instance of 'Magick::WarningOption'
  what():  ep: geometry does not contain image `foo.png' @ warning/transform.c/CropImage/574
Aborted (core dumped)
foo.png as reported by -verbose is:
foo.png PNG 4517x5906 5218x7112+338+205 8-bit PseudoClass 2c 385KB 0.190u 0:00.100

I am not sure if this is a bug in the documentation, magick++, or me. Any help would be great. Thanks.

-seth

Re: Sample from introduction to magick++ fails

Posted: 2014-03-26T10:07:18-07:00
by snibgo
In foo.png, the image starts at coordinate (338,205), so the chops operate on an area outside the image. I suggest you do the Magick++ equivalent of the command-line option "+repage" before the chops.

Re: Sample from introduction to magick++ fails

Posted: 2014-03-26T10:20:46-07:00
by seth5744
Thanks. Works a charm.