Skip to content

Commit 6e7c1d0

Browse files
authored
Merge pull request #422 from reinfallt/png_iTXt_compressed
Fixed PNG compressed iTXt chunk
2 parents 177c866 + f0e3ae6 commit 6e7c1d0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

MetadataExtractor/Formats/Png/PngMetadataReader.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ private static IEnumerable<Directory> ProcessChunk(PngChunk chunk)
264264
{
265265
if (compressionMethod == 0)
266266
{
267-
if (!TryDeflate(bytes, bytesLeft, out textBytes, out string? errorMessage))
267+
reader.Skip(2); // Skip over the zlib header bytes (78 9C)
268+
bytesLeft -= 2;
269+
if (!TryDeflate(reader.GetBytes(bytesLeft), bytesLeft, out textBytes, out string? errorMessage))
268270
{
269271
var directory = new PngDirectory(PngChunkType.iTXt);
270272
directory.AddError($"Exception decompressing PNG {nameof(PngChunkType.iTXt)} chunk with keyword \"{keyword}\": {errorMessage}");

0 commit comments

Comments
 (0)