How to extract a specific element from EXIF photographic metadata?
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
Here is something based on FilterRules
and using your post of Exif metadata format.
FilterRules
FilterRules["Exif" /. (MetaInformation /. Options[i, MetaInformation]), "XResolution"]
{"XResolution" -> 300}
There may be more elegant ways to extract the rules which form part of MetaInformation
, I await them with interest.
This unpacks nested sets of rules:
FilterRules[ Options[i, MetaInformation] //. {_ -> z_} -> z, "XResolution"]
{"XResolution" -> 300}
OptionValue
Here is an interesting alternative which does require some knowledge of the structure of the MetaInformation
but is otherwise nicely concise.
OptionValue[Options[i, MetaInformation], MetaInformation -> "Exif" -> "XResolution"]
300