Sample from introduction to magick++ fails

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
seth5744
Posts: 4
Joined: 2014-03-26T09:41:41-07:00
Authentication code: 6789

Sample from introduction to magick++ fails

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Sample from introduction to magick++ fails

Post 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.
snibgo's IM pages: im.snibgo.com
seth5744
Posts: 4
Joined: 2014-03-26T09:41:41-07:00
Authentication code: 6789

Re: Sample from introduction to magick++ fails

Post by seth5744 »

Thanks. Works a charm.
Post Reply