@@ -25,6 +25,29 @@ ExifData::const_iterator findMetadatum(const ExifData& ed, const char* const key
2525 return ed.end ();
2626} // findMetadatum
2727
28+ /* !
29+ @brief Search \em ed for a Metadatum specified by the \em keys.
30+ The \em keys are searched in the order of their appearance, the
31+ first available Metadatum is returned, except it is in NikonLd4
32+ and its value 0.
33+ Example: Exif.NikonLd4.LensID and Exif.NikonLd4.LensIDNumber are
34+ usually together included, one of them has value 0 (which means
35+ undefined), so skip tag with value 0.
36+
37+ @param ed The %Exif metadata container to search
38+ @param keys Array of keys to look for
39+ @param count Number of elements in the array
40+ */
41+ ExifData::const_iterator findMetadatumSkip0inNikonLd4 (const ExifData& ed, const char * const keys[], size_t count) {
42+ for (size_t i = 0 ; i < count; ++i) {
43+ auto pos = ed.findKey (ExifKey (keys[i]));
44+ if (pos != ed.end ()) {
45+ if (strncmp (keys[i], " Exif.NikonLd4" , 13 ) != 0 || pos->getValue ()->toInt64 (0 ) > 0 )
46+ return pos;
47+ }
48+ }
49+ return ed.end ();
50+ } // findMetadatumSkip0inNikonLd4
2851} // anonymous namespace
2952
3053// *****************************************************************************
@@ -201,7 +224,6 @@ ExifData::const_iterator sceneMode(const ExifData& ed) {
201224 " Exif.Panasonic.SceneMode" ,
202225 " Exif.Pentax.PictureMode" ,
203226 " Exif.PentaxDng.PictureMode" ,
204- " Exif.Photo.SceneCaptureType" ,
205227 };
206228 return findMetadatum (ed, keys, std::size (keys));
207229}
@@ -263,26 +285,18 @@ ExifData::const_iterator lensName(const ExifData& ed) {
263285 " Exif.Nikon3.Lens" ,
264286 };
265287
266- for (const auto & key : keys) {
267- auto pos = ed.findKey (ExifKey (key));
268- if (pos != ed.end ()) {
269- // Exif.NikonLd4.LensID and Exif.NikonLd4.LensIDNumber are usually together included,
270- // one of them has value 0 (which means undefined), so skip tag with value 0
271- if (strncmp (key, " Exif.NikonLd4" , 13 ) != 0 || pos->getValue ()->toInt64 (0 ) > 0 )
272- return pos;
273- }
274- }
275- return ed.end ();
288+ return findMetadatumSkip0inNikonLd4 (ed, keys, std::size (keys));
276289}
277290
278291ExifData::const_iterator saturation (const ExifData& ed) {
279292 static constexpr const char * keys[] = {
280293 " Exif.Photo.Saturation" , " Exif.CanonCs.Saturation" , " Exif.MinoltaCsNew.Saturation" ,
281294 " Exif.MinoltaCsOld.Saturation" , " Exif.MinoltaCs7D.Saturation" , " Exif.MinoltaCs5D.Saturation" ,
282- " Exif.Fujifilm.Color" , " Exif.Nikon3.Saturation" , " Exif.NikonPc.Saturation" ,
283- " Exif.Panasonic.Saturation" , " Exif.Pentax.Saturation" , " Exif.PentaxDng.Saturation" ,
284- " Exif.Sigma.Saturation" , " Exif.Sony1.Saturation" , " Exif.Sony2.Saturation" ,
285- " Exif.Casio.Saturation" , " Exif.Casio2.Saturation" , " Exif.Casio2.Saturation2" ,
295+ " Exif.Fujifilm.Color" , " Exif.Nikon3.Saturation" , " Exif.Nikon3.Saturation2" ,
296+ " Exif.NikonPc.Saturation" , " Exif.Panasonic.Saturation" , " Exif.Pentax.Saturation" ,
297+ " Exif.PentaxDng.Saturation" , " Exif.Sigma.Saturation" , " Exif.Sony1.Saturation" ,
298+ " Exif.Sony2.Saturation" , " Exif.Casio.Saturation" , " Exif.Casio2.Saturation" ,
299+ " Exif.Casio2.Saturation2" ,
286300 };
287301 return findMetadatum (ed, keys, std::size (keys));
288302}
@@ -418,10 +432,11 @@ ExifData::const_iterator subjectDistance(const ExifData& ed) {
418432 " Exif.Photo.SubjectDistance" , " Exif.Image.SubjectDistance" , " Exif.CanonSi.SubjectDistance" ,
419433 " Exif.CanonFi.FocusDistanceUpper" , " Exif.CanonFi.FocusDistanceLower" , " Exif.MinoltaCsNew.FocusDistance" ,
420434 " Exif.Nikon1.FocusDistance" , " Exif.Nikon3.FocusDistance" , " Exif.NikonLd2.FocusDistance" ,
421- " Exif.NikonLd3.FocusDistance" , " Exif.NikonLd4.FocusDistance" , " Exif.Olympus.FocusDistance" ,
422- " Exif.OlympusFi.FocusDistance" , " Exif.Casio.ObjectDistance" , " Exif.Casio2.ObjectDistance" ,
435+ " Exif.NikonLd3.FocusDistance" , " Exif.NikonLd4.FocusDistance" , " Exif.NikonLd4.FocusDistance2" ,
436+ " Exif.Olympus.FocusDistance" , " Exif.OlympusFi.FocusDistance" , " Exif.Casio.ObjectDistance" ,
437+ " Exif.Casio2.ObjectDistance" ,
423438 };
424- return findMetadatum (ed, keys, std::size (keys));
439+ return findMetadatumSkip0inNikonLd4 (ed, keys, std::size (keys));
425440}
426441
427442ExifData::const_iterator lightSource (const ExifData& ed) {
@@ -453,11 +468,12 @@ ExifData::const_iterator serialNumber(const ExifData& ed) {
453468
454469ExifData::const_iterator focalLength (const ExifData& ed) {
455470 static constexpr const char * keys[] = {
456- " Exif.Photo.FocalLength" , " Exif.Image.FocalLength" , " Exif.Canon.FocalLength" ,
457- " Exif.NikonLd2.FocalLength" , " Exif.NikonLd3.FocalLength" , " Exif.MinoltaCsNew.FocalLength" ,
458- " Exif.Pentax.FocalLength" , " Exif.PentaxDng.FocalLength" , " Exif.Casio2.FocalLength" ,
471+ " Exif.Photo.FocalLength" , " Exif.Image.FocalLength" , " Exif.Canon.FocalLength" ,
472+ " Exif.NikonLd2.FocalLength" , " Exif.NikonLd3.FocalLength" , " Exif.NikonLd4.FocalLength2" ,
473+ " Exif.MinoltaCsNew.FocalLength" , " Exif.Pentax.FocalLength" , " Exif.PentaxDng.FocalLength" ,
474+ " Exif.Casio2.FocalLength" ,
459475 };
460- return findMetadatum (ed, keys, std::size (keys));
476+ return findMetadatumSkip0inNikonLd4 (ed, keys, std::size (keys));
461477}
462478
463479ExifData::const_iterator subjectArea (const ExifData& ed) {
0 commit comments