From 05782b710ad18e4e8cfaf4c868692775fd1815e0 Mon Sep 17 00:00:00 2001 From: aradhyacp Date: Sat, 10 Jan 2026 01:23:31 +0530 Subject: [PATCH] Fix IHDR chunk extraction to return only the chunk itself --- aperisolve/utils/png.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aperisolve/utils/png.py b/aperisolve/utils/png.py index ff319c7..05fd1fb 100644 --- a/aperisolve/utils/png.py +++ b/aperisolve/utils/png.py @@ -57,8 +57,9 @@ class PNG: pos = data.find(b"IHDR") if pos == -1: return -1, b"" - idat_begin = data.find(b"IDAT") - return pos, data[pos - 4 : idat_begin - 4 if idat_begin != -1 else pos + 21] + # IHDR chunk is always 25 bytes: 4 (length) + 4 (type) + 13 (data) + 4 (CRC) + # Only return the IHDR chunk itself, not everything up to IDAT + return pos, data[pos - 4 : pos + 21] def check_header(self) -> bool: """Check and fix PNG header."""