Message Boards Message Boards

2
|
8505 Views
|
5 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Problems adding Exif Metadata to Images

Posted 11 years ago
I am trying to write a program to embed data into specimens images from a zoological database. I plan to do this using the MetaInformation option for Image. For some reason I cannot understand the MetaInformation for Exif is not exporting to the jpeg's I am creating. The revelvant documentation can be found [url="http://reference.wolfram.com/mathematica/ref/format/JPEG.html":]here. My code is as follows:
 diskGraphic = Graphics[Disk[]];
 
 diskWithMetaData = Image[diskGraphic, MetaInformation -> {"Test Name" -> "Test Value"}];
 
 Options[diskWithMetaData, MetaInformation]
 
 SetDirectory[NotebookDirectory[]];
 Export["diskWithMetaData.jpg", diskWithMetaData];
 
impdiskWithMetaData = =Import[FileNameJoin[{NotebookDirectory[], "diskWithMetaData.jpg"}], "ImageWithExif"];
Options[impdiskWithMetaData, MetaInformation]
I think I am missing something very fundamental in the export process but I do not know what.

Thank you for your help,
Whit
POSTED BY: Whit Farnum
5 Replies
Posted 11 years ago
I asked around and was told that "ImageWithExif" is definitely not supported for Export with JPEG, so the example I gave above was misleading. On the other hand, I was informed that it should actually work as specified in the paragraph Jason noted:

'For the "ImageWithExif" element, the Exif tags are embedded using the MetaInformation option of the imported Image object under the name "Exif". The embedded Exif tags are automatically exported when exporting as JPEG.'

However, this currently isn't the case (in my 9.0.1 on Windows):

 test =
   Import["http://www.exif.org/samples/canon-ixus.jpg",
    "ImageWithExif"];
 test // Head
 
 (* Out: Image *)
 
 "Exif" /. (MetaInformation /.
     Options[test, MetaInformation]) // Length

(* Out: 41 *)

retest =
  ImportString[ExportString[test, "JPEG"], "ImageWithExif"];
retest // Head

(* Out: Image *)

"Exif" /. (MetaInformation /.
    Options[retest, MetaInformation]) // Length

(* Out: 0 *)

I've passed this along to our team.
POSTED BY: William Rummler
Posted 11 years ago
The second paragraph and fourth and fifth sub-paragraphs under Elements at ref/format/JPEG indicate that Exif is currently supported only by Import, not by Export.
POSTED BY: William Rummler
I thought that too, that they just don't support exporting EXIF data.  But then I read "The embedded Exif tags are automatically exported when exporting as JPEG." and it made me think that they do export EXIF data.

I gave this problem a go, but had no luck.  I even downloaded a jpeg with lots of EXIF data from the web and imported it into MMA, but could not get it to export it with the EXIF data.
POSTED BY: Jason Biggs
Posted 11 years ago
The wording of that paragraph does seem a little odd in light of this behavior:

 In[2]:= test =
   Import["http://www.exif.org/samples/canon-ixus.jpg",
    "ImageWithExif"];
 test // Head
 
 Out[3]= Image
 
 In[4]:= "Exif" /. (MetaInformation /.
     Options[test, MetaInformation]) // Length

Out[4]= 41

In[5]:= Export["test.jpg", test, "ImageWithExif"]

During evaluation of In[5]:= Export::inselem: There are insufficient elements to export to JPEG format. >>

Out[5]= $Failed

I'll try to look into this a bit more.
POSTED BY: William Rummler
William,

Thank you for clarifying this matter. The sentence "The embedded Exif tags are automatically exported when exporting as JPEG." was causing me confusion as the documentation seemed to be contradicting itself. I already submitted a support request on this matter. Please let me know when you know something.
POSTED BY: Whit Farnum
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract