Page 1 of 1

Magick++ does not write EXIF data?

Posted: 2010-03-22T17:25:08-07:00
by rich2449
According to the documentation it looks like I can set EXIF data via the attribute function, however I can't get it to work. Spent the last hour googling around, and can't seem to find anything useful either, only suggestions of using another program to set the EXIF data. Writing image as a JPG, so EXIF is valid in this format.


For example:

Code: Select all

image.attribute( "EXIF:Software", "hello world" );
does not appear to work.

Is it possible to set EXIF data using Magick++ ?

Re: Magick++ does not write EXIF data?

Posted: 2010-03-22T18:34:24-07:00
by magick
Magick++ updates a few EXIF attributes internally such as the image resolution and orientation. Currently it does not support user specified EXIF attributes.

Re: Magick++ does not write EXIF data?

Posted: 2010-03-23T07:30:40-07:00
by rich2449
Thank you for the clarification.

Re: Magick++ does not write EXIF data?

Posted: 2015-06-29T08:41:36-07:00
by jsanterre
Hi,

In 2010, magick wrote:
Magick++ updates a few EXIF attributes internally such as the image resolution and orientation. Currently it does not support user specified EXIF attributes.
Is there any progress in having Magick++ writing Exif (or XMP or IPTC) metadata to file?

Thanks for your help,

Julie

Re: Magick++ does not write EXIF data?

Posted: 2015-06-29T08:52:27-07:00
by fmw42
You should probably use EXIFTOOL to modify or include meta data

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T08:21:06-07:00
by jsanterre
Thanks for your answer Fred. Unfortunately, I need to find a way to make this work using Magick++ only. ImageMagick C API could be an option too but it's less desirable.

The only metadata I was able to write to file so far is a subset of the dpx tags, as specified here:

http://www.imagemagick.org/script/motion-picture.php

But to make this work, I have to call defineValue() before reading the file. So it would go like:

Code: Select all

Magick::Image image
image.defineValue( "dpx", "file.creator", "Julie Santerre" );
image.read( inputFilename );
image.write( outputFilename );
and this can't work for me since I need to read the file before knowing which metadata I need to write to the output file.

Can someone tell me if I'm doing something wrong? Would it be possible to read the input file before calling defineValue()? If not, can someone explain why this order needs to be respected? And is there another way to write metadata in ImageMagick without any external tools such as EXIFTOOL?

Thank you very much for your help,

Julie

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T08:47:52-07:00
by fmw42
I do not believe that IM has a write to meta data explicit function even for the command line. In general, IM only reads Meta data. But I will defer to any of the IM developers for a more definitive answer.

P.S. Perhaps this should be posted to the Magick++ forum.

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T08:51:14-07:00
by jsanterre
Thanks again for your very quick answer Fred!

Julie

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T08:55:11-07:00
by dlemstra
You will have to write your own exif reader/writer. For Magick.NET (C# API) I have create a class that can be used to modify the exif profile. You can find the code for that here: https://magick.codeplex.com/SourceContr ... fReader.cs. You can even find the C++ code in an older version in the git repository: https://magick.codeplex.com/SourceContr ... d95390e2bd but that might not include all bug fixes that I did later. With a git clone and checking the history you can probably make all those fixes. The link is to one of the changes. Not sure when I moved from C++ to C#.

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T09:29:27-07:00
by jsanterre
Thank you very much Dirk! This might be the path I will follow.

Do you think I could do something similar to write metadata to DPX file?

(I would need to support the DPX properties described here: http://www.imagemagick.org/script/motion-picture.php)

Thanks!

Julie

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T09:36:11-07:00
by dlemstra
It looks like that should already work with the c++ api. I will check it when I am back home. Do you have a dpx example file?

The exif reader/writer of Magick.NET are licensed under the apache licence so you can use it freely in a commercial application.

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T10:11:15-07:00
by jsanterre
Hi!

I just PM you a link to a DPX example file. Thank you.

I was in fact able to write DPX metadata to a DPX file using something like:

Code: Select all

Magick::Image image
image.defineValue( "dpx", "file.creator", "Julie Santerre" );
image.read( inputFilename );
image.write( outputFilename );
Note that the metadata needs to be set with defineValue() before the file is even read from file. If that order is not respected, no metadata is written to file... :(

I would need to read the file first, play with it, and then use defineValue() to set some DPX metadata before writing it back to file. It seems to me this should be possible somehow...

Many thanks!

Julie

Re: Magick++ does not write EXIF data?

Posted: 2015-07-02T13:41:43-07:00
by dlemstra
It seems it is a bit tricky. You should use 'attribute' to retrieve the value and 'artifact' to set the value. I don't think this is the kind of behavior you would expect so I will make sure that attribute works for both reading and writing the value in the next release of ImageMagick (6.9.1-7). For now you will have to do this:

Code: Select all

  Image img("test_file.dpx");
  std::string creator = img.attribute("dpx:file.creator");
  std::cout << creator;
  img.artifact("dpx:file.creator", "Julie Santerre");
  img.write("test_file_julie.dpx");

  Image julie("test_file_julie.dpx");
  creator = julie.attribute("dpx:file.creator");
  std::cout << creator;

Re: Magick++ does not write EXIF data?

Posted: 2015-07-03T05:37:09-07:00
by jsanterre
That's awesome. I have been trying all possible combinations using 'attribute' but never thought about using 'artifact'. It worked like a charm.

Thank you, you made my day! :)

Julie