From b45670878dc519d5a32920a85706600134b142f2 Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Thu, 17 Nov 2022 20:33:53 +0100 Subject: [PATCH] Write padding byte, because the tiff spec requires ifd offset to begin on a word boundary. --- src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs index 2013377ed6..94c2253d18 100644 --- a/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs +++ b/src/ImageSharp/Formats/Tiff/TiffEncoderCore.cs @@ -244,6 +244,12 @@ internal sealed class TiffEncoderCore : IImageEncoderInternals entriesCollector.ProcessFrameInfo(frame, imageMetadata); entriesCollector.ProcessImageFormat(this); + if (writer.Position % 2 != 0) + { + // Write padding byte, because the tiff spec requires ifd offset to begin on a word boundary. + writer.Write(0); + } + this.frameMarkers.Add((ifdOffset, (uint)writer.Position)); return this.WriteIfd(writer, entriesCollector.Entries);