Page 1 of 1

image.attribute invalid argument

Posted: 2016-03-03T12:02:19-07:00
by ralph058
Hi
I am attempting to use Magick++ image.attribute("Lens:") to extract the same string as is displayed with

identify -verbose L_Cam_1263.png | grep "Lens:"

I believe the c++ code that I need is

string metaLens;
InitializeMagick("");
Magick::Image imgMeta(imageFileName);
metaLens = imgMeta.attribute("Lens:");
cout << "string focal length = " << metaLens << endl;

where imageFileName contains a string with the full path to L_Cam_1263.png (and others as called in sequence). I am not sure if the output is supposed to be the string "Lens: 5.46" or "5.46". So, I have commented out everything after the cout line.

The printout is
string focal length =

With no value for the string metaLens.

The compiler does not show an error, but Eclipse shows a wavy red underline, which means a problem and the mouse over shows

Invalid arguments '
Candidates are:
void attribute(?, ?)
? attribute(?)
'
The source for Magick::Image::attribute shows the declaration (at line 2036) of and the return is value
std::string Magick::Image::attribute(const std::string name_) const

what is wrong here. Is this some funky Eclipse problem? The include paths and linking is correct or I would have problems with the other artifacts from Magick++. C++11 is properly set or I would have problems with 'stof' (elsewhere in the program).

Re: image.attribute invalid argument

Posted: 2016-03-03T12:21:35-07:00
by snibgo
Try it without the colon, ie "Lens".