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 ca12a10e..f502286a 100644 Binary files a/test/data/bugfixes-test.out and b/test/data/bugfixes-test.out differ 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