How to get the image comment back?

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
Legenbaer

How to get the image comment back?

Post by Legenbaer »

OS: WinXP + MS Visual Studio 2005
IM: 6.3.7


Hello Guys,

after solving my first problem now i´ve got a secound. ^^ I try to append a comment to the picture. This part of the story works (i can see the comment using the commandlinetool) but in C++ i don´t no how to get this comment back. I need the comment as a string-value. Please help me. :| Any ideas?

#include <Magick++.h>
#include <string>
#include <iostream>
#include <list>

using namespace std;

using namespace Magick;

int main( int argc, char ** argv)
{

// Initialize ImageMagick install location for Windows
/* InitializeMagick(*argv); */

string srcdir("");
if(getenv("SRCDIR") != 0)
srcdir = getenv("SRCDIR");
try
{
Image test;
test.read(srcdir + "smile2.png");
test.comment("blablabla");
test.verbose(); //verbose don´t show anything
test.write("smile3.png");
} catch( Exception &error_ ) {
cout << "Caught exception: " << error_.what() << endl;
return 1;
}

return 0;

}

greetings ;)
Legenbaer

Re: How to get the image comment back?

Post by Legenbaer »

Wow...it was easier than i thought:

string xyz = test.attribute("comment");

greetings
Post Reply