From c1d8fe6da101a22f901880c3ee58e59eea04c81d Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Wed, 13 Sep 2023 14:31:44 -0700 Subject: [PATCH] fix(png): Write out proper tiff header version in png EXIF blobs (#3984) When writing out EXIF headers in PNG files, the `tiff_version` field wasn't handling endianness properly. This lead to some tools like `exiv2` refusing to process the file at all[1] [1] https://github.com/Exiv2/exiv2/issues/2745 --------- Signed-off-by: Jesse Yurkovich --- src/libOpenImageIO/exif.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libOpenImageIO/exif.cpp b/src/libOpenImageIO/exif.cpp index 90eaaec6e9..1fbf04140e 100644 --- a/src/libOpenImageIO/exif.cpp +++ b/src/libOpenImageIO/exif.cpp @@ -1302,6 +1302,8 @@ encode_exif(const ImageSpec& spec, std::vector& blob, TIFFHeader head; head.tiff_magic = (endianreq == endian::little) ? 0x4949 : 0x4d4d; head.tiff_version = 42; + if (endianreq != endian::native) + swap_endian(&head.tiff_version); // N.B. need to swap_endian head.tiff_diroff below, once we know the sizes append(blob, head);