How to cut pictures with the 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
cnhome

How to cut pictures with the Magick++?

Post by cnhome »

I write the following code, and I find some black region in the result. It is not that I want to be cut. How can I write the code?


#include <Magick++.h>
#include <iostream>
#include <string>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
InitializeMagick("C:\\Program Files\\ImageMagick-6.6.2-Q16\\");
Image image;
try {

string file_name0 = "d:\\test.jpg";
image.read(file_name0);

image.chop(Geometry(20,20));
image.crop(Geometry(60,50));

image.write("d:\\test0.gif");
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}


The picture and reuslt as following:

test.jpg

http://mail.qq.com/cgi-bin/ftnExs_downl ... e=d81d27c1

test0.gif

http://mail.qq.com/cgi-bin/ftnExs_downl ... e=c5076ede
Post Reply