diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index fcbbc6697..34d5ee773 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -149,10 +149,10 @@ namespace SixLabors.ImageSharp.Formats.Png stream.Write(PngConstants.HeaderBytes); this.WriteHeaderChunk(stream); + this.WriteGammaChunk(stream); this.WritePaletteChunk(stream, quantized); this.WriteTransparencyChunk(stream, pngMetadata); this.WritePhysicalChunk(stream, metadata); - this.WriteGammaChunk(stream); this.WriteExifChunk(stream, metadata); this.WriteTextChunks(stream, pngMetadata); this.WriteDataChunks(image.Frames.RootFrame, quantized, stream); @@ -538,6 +538,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the palette chunk to the stream. + /// Should be written before the first IDAT chunk. /// /// The pixel format. /// The containing image data. @@ -595,6 +596,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the physical dimension information to the stream. + /// Should be written before IDAT chunk. /// /// The containing image data. /// The image metadata. @@ -716,6 +718,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the gamma information to the stream. + /// Should be written before PLTE and IDAT chunk. /// /// The containing image data. private void WriteGammaChunk(Stream stream) @@ -733,6 +736,7 @@ namespace SixLabors.ImageSharp.Formats.Png /// /// Writes the transparency chunk to the stream. + /// Should be written after PLTE and before IDAT. /// /// The containing image data. /// The image metadata.