From 81265684f064f193a6fcdd2073da2e2e7e6dcd6e Mon Sep 17 00:00:00 2001 From: Robin Mills Date: Sat, 12 Nov 2016 22:08:10 +0000 Subject: [PATCH] #1108 Fixed bugs in printStructure(kpsRecursive) handling of RATIONAL data. --- include/exiv2/image.hpp | 1 + src/image.cpp | 23 +++++++++++++---------- test/data/bugfixes-test.out | Bin 1928392 -> 1928430 bytes test/data/icc-test.out | 36 ++++++++++++++++++------------------ test/data/stdin-test.out | 4 ++-- test/data/tiff-test.out | 8 ++++---- test/data/webp-test.out | 24 ++++++++++++------------ 7 files changed, 50 insertions(+), 46 deletions(-) diff --git a/include/exiv2/image.hpp b/include/exiv2/image.hpp index 7ba84b33..a60d3845 100644 --- a/include/exiv2/image.hpp +++ b/include/exiv2/image.hpp @@ -346,6 +346,7 @@ namespace Exiv2 { bool isRationalType(uint16_t type); bool is2ByteType(uint16_t type); bool is4ByteType(uint16_t type); + bool is8ByteType(uint16_t type); bool isPrintXMP(uint16_t type, Exiv2::PrintStructureOption option); bool isPrintICC(uint16_t type, Exiv2::PrintStructureOption option); diff --git a/src/image.cpp b/src/image.cpp index 66859c35..8fa3fff5 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -205,7 +205,14 @@ namespace Exiv2 { bool Image::is4ByteType(uint16_t type) { return isLongType(type) - || isRationalType(type) + || type == Exiv2::tiffFloat + || type == Exiv2::tiffIfd + ; + } + bool Image::is8ByteType(uint16_t type) + { + return isRationalType(type) + || type == Exiv2::tiffDouble ; } bool Image::isPrintXMP(uint16_t type, Exiv2::PrintStructureOption option) @@ -317,6 +324,7 @@ namespace Exiv2 { case Exiv2::signedRational : result = "SRATIONAL" ; break; case Exiv2::tiffFloat : result = "FLOAT" ; break; case Exiv2::tiffDouble : result = "DOUBLE" ; break; + case Exiv2::tiffIfd : result = "IFD" ; break; default : result = "unknown" ; break; } return result; @@ -374,6 +382,7 @@ namespace Exiv2 { uint32_t size = isStringType(type) ? 1 : is2ByteType(type) ? 2 : is4ByteType(type) ? 4 + : is8ByteType(type) ? 8 : 1 ; @@ -405,15 +414,9 @@ namespace Exiv2 { } else if ( isRationalType(type) ){ for ( size_t k = 0 ; k < kount ; k++ ) { - uint16_t a = byteSwap2(buf,k*size+0,bSwap); - uint16_t b = byteSwap2(buf,k*size+2,bSwap); - if ( isLittleEndianPlatform() ) { - if ( bSwap ) out << sp << b << "/" << a; - else out << sp << a << "/" << b; - } else { - if ( bSwap ) out << sp << a << "/" << b; - else out << sp << b << "/" << a; - } + uint32_t a = byteSwap4(buf,k*size+0,bSwap); + uint32_t b = byteSwap4(buf,k*size+4,bSwap); + out << sp << a << "/" << b; sp = " "; } } else if ( isStringType(type) ) { diff --git a/test/data/bugfixes-test.out b/test/data/bugfixes-test.out index ca12a10ecf04a9817e4f5fad64e122f9e0bf47da..f502286a495e527a22983e4e17ca13e39ab65024 100644 GIT binary patch delta 904 zcmZ8g&r4N76z2X?)8~C^`b^)c-YS>(&fK~4=2l?2sa8t7o`RJGR$7q#z(o)tIRAhl z%_hyXH3~?qQMlyhY0L{z%mTCGSHG(K6bz~#{m`Rkr(i(O_CwJ&fcniz`0Aypds6;G=#^98 zTU{i?4Z|wL8fNB(#QW2*>^lUb8^f^e?C4Qrqfn|z+ZYA6X^#Vf?l_Pg-*q5A4nsEL zFm>|^3Z$r6f4TzStW^E#1eEiP7kL;*K};DHV%N?>M7f%)!Vxty0f%x#6z&xWA%Y1) zf+&h(#v-aNPC~hjP{u=!yctPY6f(Ur39jYF#=&>jfHa~ZM4=%$<==+CohY)Vmg_pjT0At6#_G=_IG5S!6v8RxTrI8Ry`hKDuGbdeqvbHo4`DRSb~z} zGUM6&6X^4NgfspakR+k%)_v$#l`?p`V+9^GWsr**C<)tbbq$Nw?`W$6)NxZrVjbHK zUt7&eKI1GB*mbqN*(!|K$ns|uAq>mo8qU{PF1~~> hZno~9AS7mn<_Z1w6)ZZg@l%a&LMe^(>rH5W_74Du?A8DP delta 750 zcmX|8J8KkC6lQ1VPBw{I&D+Njwo*alK4$LB9W69AYPaYn5jFusG?)YtloS#Ki-VO- zY;LuvDFg*E5R)4O5d}q5d=!DCun1Nns6WATN8%KBzVE!xcYbZoz1y6-g(VEIj3F|N zunjBNjvd&EJFp9@xD$6_H}+sJ_F+E`;2`eCJ-8S5J%cV4$}Hu!HVJ+9_5vKU7ZgNH znuH5CtDqHxS**CNY8VZ(L~u8w;d{U`W4N$&10yWUQ-Y5OhDIdZm2(&`g+?mwE**u5 zut(ICrjS~!sc3=i&{e2AaUAXj%m_uT-VDJy>)nq07hk+?VYB#DXGD@|w+PJG?BO$aMYX5RjJ5*oCbHy^qP^?>QbPd-0IOK3lv zTc3iB5=;F=cIh&iQ{UD0O&8E_JYPUXd2VYOLJIaR-H#cNZA|Bq@cwJi|9@b;J+H8T zPQrj2zYarDd(2gy)+pG@Gi3a90~QCFDI}d+fV0eaN!`Z<80)NPp_Jh&u}4}k+$L0< z5^>mq1A+I^p~&~-9yC15m1p7og2mLELYu@&q%-^+9W diff --git a/test/data/icc-test.out b/test/data/icc-test.out index 9f44d87f..6b555867 100644 --- a/test/data/icc-test.out +++ b/test/data/icc-test.out @@ -477,8 +477,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -512,8 +512,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -546,8 +546,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -579,8 +579,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -614,8 +614,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -648,8 +648,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -681,8 +681,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -716,8 +716,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 @@ -750,8 +750,8 @@ STRUCTURE OF TIFF FILE (II): ReaganLargeTiff.tiff 154 | 0x0115 SamplesPerPixel | SHORT | 1 | 3 | 3 166 | 0x0116 RowsPerStrip | SHORT | 1 | 128 | 128 178 | 0x0117 StripByteCounts | LONG | 2 | 880 | 43883 931 - 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 888/0 - 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 896/0 + 190 | 0x011a XResolution | RATIONAL | 1 | 888 | 300/1 + 202 | 0x011b YResolution | RATIONAL | 1 | 896 | 300/1 214 | 0x011c PlanarConfiguration | SHORT | 1 | 1 | 1 226 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 238 | 0x0131 Software | ASCII | 11 | 904 | GIMP 2.9.5 diff --git a/test/data/stdin-test.out b/test/data/stdin-test.out index c051f728..ca90eb86 100644 --- a/test/data/stdin-test.out +++ b/test/data/stdin-test.out @@ -248,8 +248,8 @@ STRUCTURE OF TIFF FILE (MM): Reagan.tiff 130 | 0x0115 SamplesPerPixel | SHORT | 1 | 262144 | 4 142 | 0x0116 RowsPerStrip | SHORT | 1 | 8519680 | 130 154 | 0x0117 StripByteCounts | LONG | 1 | 104000 | 104000 - 166 | 0x011a XResolution | RATIONAL | 1 | 778 | 778/0 - 178 | 0x011b YResolution | RATIONAL | 1 | 786 | 786/0 + 166 | 0x011a XResolution | RATIONAL | 1 | 778 | 300/1 + 178 | 0x011b YResolution | RATIONAL | 1 | 786 | 300/1 190 | 0x011c PlanarConfiguration | SHORT | 1 | 65536 | 1 202 | 0x0128 ResolutionUnit | SHORT | 1 | 131072 | 2 214 | 0x0131 Software | ASCII | 29 | 794 | Adobe Photoshop CS Macintosh diff --git a/test/data/tiff-test.out b/test/data/tiff-test.out index ca4c1c92..a59f8f39 100644 --- a/test/data/tiff-test.out +++ b/test/data/tiff-test.out @@ -31,8 +31,8 @@ Orientation SHORT 1 "1" SamplesPerPixel SHORT 1 "3" RowsPerStrip SHORT 1 "64" StripByteCounts LONG 1 "243" -XResolution RATIONAL 1 "510/0" -YResolution RATIONAL 1 "518/0" +XResolution RATIONAL 1 "1207959552/16777216" +YResolution RATIONAL 1 "1207959552/16777216" PlanarConfiguration SHORT 1 "1" ResolutionUnit SHORT 1 "2" @@ -118,8 +118,8 @@ Orientation SHORT 1 "1" SamplesPerPixel SHORT 1 "3" RowsPerStrip SHORT 1 "64" StripByteCounts LONG 1 "243" -XResolution RATIONAL 1 "278/0" -YResolution RATIONAL 1 "286/0" +XResolution RATIONAL 1 "1207959552/16777216" +YResolution RATIONAL 1 "1207959552/16777216" PlanarConfiguration SHORT 1 "1" ResolutionUnit SHORT 1 "2" ExifTag LONG 1 "294" diff --git a/test/data/webp-test.out b/test/data/webp-test.out index 1ae9fc49..e92a8441 100644 --- a/test/data/webp-test.out +++ b/test/data/webp-test.out @@ -22,8 +22,8 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 58 | 0x010f Make | ASCII | 18 | 238 | NIKON CORPORATION 70 | 0x0110 Model | ASCII | 12 | 256 | NIKON D5300 82 | 0x0112 Orientation | SHORT | 1 | 1 | 1 - 94 | 0x011a XResolution | RATIONAL | 1 | 268 | 268/0 - 106 | 0x011b YResolution | RATIONAL | 1 | 276 | 276/0 + 94 | 0x011a XResolution | RATIONAL | 1 | 268 | 300/1 + 106 | 0x011b YResolution | RATIONAL | 1 | 276 | 300/1 118 | 0x0128 ResolutionUnit | SHORT | 1 | 2 | 2 130 | 0x0131 Software | ASCII | 11 | 284 | GIMP 2.9.5 142 | 0x0132 DateTime | ASCII | 20 | 296 | 2016:08:13 10:54:16 @@ -31,8 +31,8 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 166 | 0x8769 ExifTag | LONG | 1 | 316 | 316 STRUCTURE OF TIFF FILE (II): MemIo address | tag | type | count | offset | value - 318 | 0x829a ExposureTime | RATIONAL | 1 | 814 | 814/0 - 330 | 0x829d FNumber | RATIONAL | 1 | 822 | 822/0 + 318 | 0x829a ExposureTime | RATIONAL | 1 | 814 | 10/4000 + 330 | 0x829d FNumber | RATIONAL | 1 | 822 | 100/10 342 | 0x8822 ExposureProgram | SHORT | 1 | 0 | 0 354 | 0x8827 ISOSpeedRatings | SHORT | 1 | 200 | 200 366 | 0x8830 SensitivityType | SHORT | 1 | 2 | 2 @@ -40,13 +40,13 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 390 | 0x9003 DateTimeOriginal | ASCII | 20 | 830 | 2015:07:16 15:38:54 402 | 0x9004 DateTimeDigitized | ASCII | 20 | 850 | 2015:07:16 15:38:54 414 | 0x9101 ComponentsConfiguration | UNDEFINED | 4 | 197121 | ... - 426 | 0x9102 CompressedBitsPerPixel | RATIONAL | 1 | 870 | 870/0 - 438 | 0x9204 ExposureBiasValue | SRATIONAL | 1 | 878 | 878/0 - 450 | 0x9205 MaxApertureValue | RATIONAL | 1 | 886 | 886/0 + 426 | 0x9102 CompressedBitsPerPixel | RATIONAL | 1 | 870 | 2/1 + 438 | 0x9204 ExposureBiasValue | SRATIONAL | 1 | 878 | 0/6 + 450 | 0x9205 MaxApertureValue | RATIONAL | 1 | 886 | 43/10 462 | 0x9207 MeteringMode | SHORT | 1 | 5 | 5 474 | 0x9208 LightSource | SHORT | 1 | 0 | 0 486 | 0x9209 Flash | SHORT | 1 | 16 | 16 - 498 | 0x920a FocalLength | RATIONAL | 1 | 894 | 894/0 + 498 | 0x920a FocalLength | RATIONAL | 1 | 894 | 440/10 510 | 0x927c MakerNote | UNDEFINED | 3826 | 902 | Nikon.....II*.....9.+...$...... ... STRUCTURE OF TIFF FILE (II): MemIo address | tag | type | count | offset | value @@ -67,7 +67,7 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 178 | 0x008a | SHORT | 1 | 1 | 1 190 | 0x001e GPSDifferential | SHORT | 1 | 1 | 1 202 | 0x001b GPSProcessingMethod | SHORT | 7 | 2032 | 0 6016 4016 6016 4016 ... - 214 | 0x0019 GPSDestDistanceRef | SRATIONAL | 1 | 2046 | 2046/0 + 214 | 0x0019 GPSDestDistanceRef | SRATIONAL | 1 | 2046 | 0/6 226 | 0x000e GPSTrackRef | UNDEFINED | 4 | 786688 | ... 238 | 0x001c GPSAreaInformation | SHORT | 3 | 2054 | 0 1 6 250 | 0x0018 GPSDestBearing | UNDEFINED | 4 | 393472 | ... @@ -83,7 +83,7 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 370 | 0x0002 ISOSpeed | SHORT | 2 | 13107200 | 0 200 382 | 0x0016 GPSDestLongitude | SHORT | 4 | 2152 | 0 0 6000 4000 394 | 0x00a2 | LONG | 1 | 6173648 | 6173648 - 406 | 0x0084 | RATIONAL | 4 | 2160 | 180/0 10/0 2500/0 10/0 + 406 | 0x0084 | RATIONAL | 4 | 2160 | 180/10 2500/10 35/10 63/10 418 | 0x008b | UNDEFINED | 4 | 786743 | 7.. 430 | 0x0083 | BYTE | 1 | 14 | . 442 | 0x0095 | ASCII | 5 | 2192 | OFF @@ -95,7 +95,7 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 514 | 0x00a7 | LONG | 1 | 9608 | 9608 526 | 0x00ab | ASCII | 16 | 2234 | AUTO(FLASH OFF) 538 | 0x0001 Version | UNDEFINED | 4 | 825307696 | 0211 - 550 | 0x000c GPSSpeedRef | RATIONAL | 4 | 2250 | 538/0 256/0 354/0 256/0 + 550 | 0x000c GPSSpeedRef | RATIONAL | 4 | 2250 | 538/256 354/256 256/256 256/256 562 | 0x0005 WhiteBalance | ASCII | 13 | 2282 | AUTO 574 | 0x000b ProcessingSoftware | SSHORT | 2 | 0 | 0 0 586 | 0x00b7 | UNDEFINED | 30 | 2296 | 0100....i.................... @@ -123,7 +123,7 @@ STRUCTURE OF WEBP FILE: exiv2-bug1199.webp 666 | 0xa401 CustomRendered | SHORT | 1 | 0 | 0 678 | 0xa402 ExposureMode | SHORT | 1 | 0 | 0 690 | 0xa403 WhiteBalance | SHORT | 1 | 0 | 0 - 702 | 0xa404 DigitalZoomRatio | RATIONAL | 1 | 4780 | 4780/0 + 702 | 0xa404 DigitalZoomRatio | RATIONAL | 1 | 4780 | 1/1 714 | 0xa405 FocalLengthIn35mmFilm | SHORT | 1 | 66 | 66 726 | 0xa406 SceneCaptureType | SHORT | 1 | 0 | 0 738 | 0xa407 GainControl | SHORT | 1 | 0 | 0