diff --git a/src/pentaxmn.cpp b/src/pentaxmn.cpp index 96fd6b93..3c3276fc 100644 --- a/src/pentaxmn.cpp +++ b/src/pentaxmn.cpp @@ -1152,37 +1152,39 @@ namespace Exiv2 { const ExifData* metadata) { try { - unsigned long lensID = value.toLong(0)*256 + value.toLong(1); - unsigned long index = 0; + unsigned long lensID = value.toLong(0)*256 + value.toLong(1); // 0x3ff + unsigned long index = 0; + + const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo")) != metadata->end() + ? metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo")) + : metadata->findKey(ExifKey("Exif.Pentax.LensInfo")) + ; + if ( lensInfo == metadata->end() ) return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata); + if ( lensInfo->count() < 5 ) return EXV_PRINT_COMBITAG_MULTI(pentaxLensType, 2, 1, 2)(os, value, metadata); if ( value.count() == 2 ) { - // http://dev.exiv2.org/attachments/download/326/IMGP4432.PEF - // exiv2 -pv --grep Lens ~/Downloads/IMGP4432.PEF + // http://dev.exiv2.org/attachments/download/326/IMGP4432.PEF + // exiv2 -pv --grep Lens ~/Downloads/IMGP4432.PEF // 0x003f Pentax LensType Byte 2 3 255 // 0x0207 Pentax LensInfo Undefined 36 3 255 0 0 40 148 71 152 80 6 241 65 237 153 88 36 1 76 107 251 255 255 255 0 0 80 6 241 0 0 0 0 0 0 0 0 - unsigned long base = 1; + unsigned long base = 1; - // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Pentax.html#LensData - const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.Pentax.LensInfo")); - if ( lensInfo->count() > 5 ) { - unsigned int autoAperture = lensInfo->toLong(base+1) & 0x01 ; - unsigned int minAperture = lensInfo->toLong(base+2) & 0x06 ; - unsigned int minFocusDistance = lensInfo->toLong(base+3) & 0xf8 ; - unsigned int dontKnow = lensInfo->toLong(base+4); + // http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Pentax.html#LensData + const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.Pentax.LensInfo")); + unsigned int autoAperture = lensInfo->toLong(base+1) & 0x01 ; + unsigned int minAperture = lensInfo->toLong(base+2) & 0x06 ; + unsigned int minFocusDistance = lensInfo->toLong(base+3) & 0xf8 ; + unsigned int dontKnow = lensInfo->toLong(base+4); - if ( autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && dontKnow == 148) index = 8; - } - } else if ( value.count() == 3 ) { - // http://dev.exiv2.org/attachments/download/858/_IGP9032.DNG + if ( autoAperture == 0x0 && minAperture == 0x0 && minFocusDistance == 0x28 && dontKnow == 148) index = 8; + } else if ( value.count() == 3 ) { + // http://dev.exiv2.org/attachments/download/858/_IGP9032.DNG // $ exiv2 -pv --grep Lens ~/Downloads/_IGP9032.DNG // 0x003f PentaxDng LensType Byte 3 3 255 0 // 0x0207 PentaxDng LensInfo Undefined 69 131 0 0 255 0 40 148 68 244 ... // 0 1 2 3 4 5 6 - const ExifData::const_iterator lensInfo = metadata->findKey(ExifKey("Exif.PentaxDng.LensInfo")); - if ( lensInfo->count() > 5 ) { - if ( lensInfo->toLong(4) == 0 && lensInfo->toLong(5) == 40 && lensInfo->toLong(6) == 148 ) index = 8; - } - } + if ( lensInfo->toLong(4) == 0 && lensInfo->toLong(5) == 40 && lensInfo->toLong(6) == 148 ) index = 8; + } if ( index > 0 ) { const TagDetails* td = find(pentaxLensType, lensID); diff --git a/test/bugfixes-test.sh b/test/bugfixes-test.sh index efc19634..921e4c73 100755 --- a/test/bugfixes-test.sh +++ b/test/bugfixes-test.sh @@ -222,10 +222,10 @@ source ./functions.source num=816 # test Camera: Pentax + Lens:Sigma 55-200mm F4-5.6 DC is correctly reported printf "$num " >&3 echo '------>' Bug $num '<-------' >&2 - for X in a b; do - file=exiv2-bug${num}${X}.exv - copyTestFile $file - runTest exiv2 -pa --grep Lens $file + for X in a b c d; do + filename=exiv2-bug${num}${X}.exv + copyTestFile $filename + runTest exiv2 -pa --grep Lens $filename done num=831 diff --git a/test/data/bugfixes-test.out b/test/data/bugfixes-test.out index 66f45289..7f73839b 100644 Binary files a/test/data/bugfixes-test.out and b/test/data/bugfixes-test.out differ diff --git a/test/data/exiv2-bug816c.exv b/test/data/exiv2-bug816c.exv new file mode 100644 index 00000000..d21058d7 Binary files /dev/null and b/test/data/exiv2-bug816c.exv differ diff --git a/test/data/exiv2-bug816d.exv b/test/data/exiv2-bug816d.exv new file mode 100644 index 00000000..cd662441 Binary files /dev/null and b/test/data/exiv2-bug816d.exv differ