Merge pull request #155 from aradhyacp/fix/png-PCRT-issue

fix: PCRT repaired PNG files corruption and filename extension #152
This commit is contained in:
Zeecka
2026-01-10 00:17:54 +01:00
committed by GitHub
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ class PCRTAnalyzer(SubprocessAnalyzer):
def _write_repaired_data(self, data: bytes) -> str:
"""Write recovered image."""
img_name = f"pcrt_recoverd_{self.input_img.name}.png"
img_name = f"pcrt_recovered_{self.input_img.stem}.png"
output_path = self.output_dir / img_name
saved_img_url = "/image/" + str(Path(self.output_dir.name) / img_name)
with output_path.open("wb") as f:
+3 -2
View File
@@ -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."""