Project

General

Profile

I dont manage to write xmpdata into pictures.

Added by Anonymous almost 13 years ago

int testXmp::testAgain(std::string nomImage){
try{
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(nomImage);
assert (image.get() != 0);
image->readMetadata();
//image->clearMetadata();
Exiv2::XmpData &xmpData = image->xmpData();
// Add a simple XMP property in a known namespace
Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText);
v->read("sorry");
xmpData.add(Exiv2::XmpKey("Xmp.dc.format"), v.get());
image->setXmpData(xmpData);
image->writeMetadata();
return 0;
}catch(Exiv2::AnyError& e){
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1; }
}

This will compile, with libraries and dlls, will not crash at runtime but doesn't write to the image.
I can easily read the xmp Metadata with one of the sample programs.

Like "image->writeMetadata()" does nothing.

Any hints?
Is any part of my code so nasty?

Thanks in advance for your time
Alaeri


Replies (6)

RE: I dont manage to write xmpdata into pictures. - Added by Andreas Huggel almost 13 years ago

This works fine here. Check if your library was compiled with XMP support. How? A quick hack is to add a dummy call to XmpParser::decode to the program, like

    Exiv2::XmpParser::decode(xmpData, "not empty");

That will write a warning to the screen if the library has no XMP support.

Andreas

RE: I dont manage to write xmpdata into pictures. - Added by Anonymous almost 13 years ago

That must be the warning:
XMP Toolkit error 201: XML parsing failure

xmptoolkit.a
libexpat.a

These are the libraries I have included in my project to support xmp.
I suspect I did some ** creating my exiv lib.

Thank you for your fast answer. I have eventually a starting point for debugging.

Alaeri

RE: I dont manage to write xmpdata into pictures. - Added by Andreas Huggel almost 13 years ago

No that's not the warning I get ("Warning: XMP toolkit support not compiled in"). The error that you have might mean there is XMP support and it fails to parse the dummy string provided to decode.

But you don't need an external xmptoolkit library to compile Exiv2 or an application that uses Exiv2. Maybe that confuses it. See doc/README-XMP

Is the problem with the library or the build env of the application? Do you have a working exiv2 command line tool? Does exiv2 -M'set Xmp.dc.format some text' yourImage.jpg give the expected result?

Andreas

RE: I dont manage to write xmpdata into pictures. - Added by Anonymous almost 13 years ago

Hi, I am also interested in this kind of XMP support, but it is not working for me either. I compiled the above and got the following error:
Warning: Size 13662 of Exif.Image.0xc634 exceeds 4096 bytes limit. Not decoded.
Caught Exiv2 exception 'Writing to %2 images is not supported'

Any ideas what went wrong?

David

RE: I dont manage to write xmpdata into pictures. - Added by Anonymous almost 13 years ago

Additional information about my environment:

I do have compiled support for XMP:
------------------------------------------------------------------
-- Exiv2 0.18 feature configuration summary
--
-- Build a shared library......... YES
-- Use g++ visibility support..... YES
-- PNG image support.............. YES
-- Native language support........ YES
-- Conversion of Windows XP tags.. YES
-- Nikon lens database............ YES
-- XMP metadata support........... YES
------------------------------------------------------------------

I tried compiling and running one of the sample programs, xmpparse, but it fails as well:
XMP Toolkit error 201: XML parsing failure
Caught Exiv2 exception 'test.jpg: Failed to parse file contents (XMP packet)'

David

RE: I dont manage to write xmpdata into pictures. - Added by Andreas Huggel almost 13 years ago

David,

Sounds like something's wrong with XMP support in your environment. I don't have a clue (obviously it works here), so I'll have to ask some wild questions, please bear with me.

Can you try the xmpsample program, does that work?
On what platform is this (Architecture, OS, Linux distribution if applicable, compiler)?
What commands have you used to configure and compile? Can you post/attach the complete output from configure and make?
If you're on Linux/UNIX and have the ldd program, what's the output of

ldd /path/to/xmpsample

Please rebuild from scratch and add the option --disable-visibility to ./configure Does it help?

Andreas

    (1-6/6)