It's now possible to import photographs into Mathematica and import the EXIF data at the same time:
i = Import["ExampleData/coneflower.jpg", "ImageWithExif"]
You can now look at all the metadata:
Options[i, MetaInformation]
{MetaInformation -> {"Exif" -> {"ImageDescription" -> " ", "Make" -> "NIKON", "Model" -> "E950", "Orientation" -> 1, "XResolution" -> 300, "YResolution" -> 300, "ResolutionUnit" -> 2, "Software" -> "Adobe Photoshop CS3 Macintosh", "DateTime" -> "2008:08:19 11:29:05", etc...
So how would I extract - say - the exposure time ("ExposureTime")? I was trying something like this:
"ExposureTime" /. Options[i, MetaInformation] ...
but I don't know enough about the structure of the stored metainformation. Can you do this without knowing that structure?
Answer
Does this do want you want?
Cases[Options[i, MetaInformation],
HoldPattern["ExposureTime" -> ___], Infinity]
or even simpler because it is Rule
s all the way down:
Cases[Options[i], HoldPattern["ExposureTime" -> ___], Infinity]
{"ExposureTime" -> 1/65}
All-in-one:
With[{wanted = "ExposureTime"},
wanted /. Cases[Options[i], HoldPattern[wanted -> ___], Infinity]] //
N
Comments
Post a Comment