Magick++ does not write EXIF data?

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
rich2449
Posts: 11
Joined: 2010-03-18T11:34:10-07:00
Authentication code: 8675308

Magick++ does not write EXIF data?

Post by rich2449 » 2010-03-22T17:25:08-07:00

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++ ?

User avatar
magick
Site Admin
Posts: 11100
Joined: 2003-05-31T11:32:55-07:00

Re: Magick++ does not write EXIF data?

Post by magick » 2010-03-22T18:34:24-07:00

Magick++ updates a few EXIF attributes internally such as the image resolution and orientation. Currently it does not support user specified EXIF attributes.

rich2449
Posts: 11
Joined: 2010-03-18T11:34:10-07:00
Authentication code: 8675308

Re: Magick++ does not write EXIF data?

Post by rich2449 » 2010-03-23T07:30:40-07:00

Thank you for the clarification.

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-06-29T08:41:36-07:00

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

User avatar
fmw42
Posts: 25765
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ does not write EXIF data?

Post by fmw42 » 2015-06-29T08:52:27-07:00

You should probably use EXIFTOOL to modify or include meta data

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-07-02T08:21:06-07:00

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

User avatar
fmw42
Posts: 25765
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Magick++ does not write EXIF data?

Post by fmw42 » 2015-07-02T08:47:52-07:00

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.

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-07-02T08:51:14-07:00

Thanks again for your very quick answer Fred!

Julie

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Magick++ does not write EXIF data?

Post by dlemstra » 2015-07-02T08:55:11-07:00

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#.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-07-02T09:29:27-07:00

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

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Magick++ does not write EXIF data?

Post by dlemstra » 2015-07-02T09:36:11-07:00

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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-07-02T10:11:15-07:00

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

User avatar
dlemstra
Posts: 1588
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Magick++ does not write EXIF data?

Post by dlemstra » 2015-07-02T13:41:43-07:00

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;
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate

jsanterre
Posts: 31
Joined: 2014-05-09T10:39:21-07:00
Authentication code: 6789

Re: Magick++ does not write EXIF data?

Post by jsanterre » 2015-07-03T05:37:09-07:00

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

Post Reply