I'm using GraphicsMagick in my c++ application running on Raspberry Pi. All goes well, except the "readImages" function which returns an "Magick::ErrorOpenFile" exception:
terminate called after throwing an instance of 'Magick::ErrorFileOpen'
GraphicsMagick Error: Magick: Unable to open file () reported by magick/blob.c:3061 (OpenBlob)
This is my code:
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc,char **argv){
InitializeMagick(*argv);
try {
list<Image> imageList;
std::string lFilename = "paars.jpg";
try {
// Attempt to read the image
readImages( &imageList, lFilename );
std::cout << "Image read successfully." << std::endl;
} catch (Magick::Exception &e) {
// Handle GraphicsMagick exceptions
std::cerr << "GraphicsMagick Error: " << e.what() << std::endl;
} catch (std::exception &e) {
// Handle other exceptions
std::cerr << "Error: " << e.what() << std::endl;
}
} catch (std::exception &e) {
// Handle any other exceptions in the outer block
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}
I have tried with several different images and different formats like bmp, jpg and png, but I cannot get passed the exception. The path of the images is correct, I can read the image with an Magick::Image object like so:
Magick::Image myImage( lFilename );
Any help would be greatly appreciated!