read and write image

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
msp

read and write image

Post by msp »

I am trying to run the sample code to read and write an image. Following is the code. I have installed Magick++ on my machine and still it is giving some errors which i am not able to figure out. It says magick/magick_config.h not declared. Also gives same error for all different header files. Does it because I have stored them in wrong location? or do i have to include them in the following code? Please help me.

#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv)
{
// Construct the image object. Seperating image construction from the
// the read operation ensures that a failure to read the image file
// doesn't render the image object useless.
Image image;
try {
// Read a file into image object
image.read( "girl.gif" );

// Crop the image to specified size (width, height, xOffset, yOffset)
image.crop( Geometry(100,100, 100, 100) );

// Write the image to a file
image.write( "x.gif" );
}
catch( Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: read and write image

Post by anthony »

Was the header files installed? Do you have the right -I include flag to find the header files?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply