Test files › Images › png-truncated.png

Truncated PNG test file

Valid PNG header and partial IDAT, cut off before IEND.

↓ Download png-truncated.png
Filenamepng-truncated.png
FormatPNG
Size719 bytes (719 bytes)
MIME typeimage/png
SHA-2565442ebef90a3212ce5fec1b88eb613bcf13ea075d7974af9bdd09700f3f45514
What this file catchesDecoders that return a half-drawn image rather than an error, and upload validators that only sniff the first 8 magic bytes.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

Walk the chunks and verify each CRC. Browsers tolerate damage that strict decoders reject, so check before you store or process the image.

import struct, zlib

with open("png-truncated.png", "rb") as f:
    data = f.read()
if data[:8] != b"\x89PNG\r\n\x1a\n":
    raise SystemExit("not a PNG")

pos = 8
while True:
    if pos + 8 > len(data):
        raise SystemExit("truncated: the file ends before an IEND chunk")
    length, ctype = struct.unpack(">I4s", data[pos:pos + 8])
    end = pos + 12 + length
    if end > len(data):
        raise SystemExit(f"truncated: the {ctype.decode()} chunk needs {length} bytes")
    if zlib.crc32(data[pos + 4:end - 4]) != struct.unpack(">I", data[end - 4:end])[0]:
        raise SystemExit(f"bad CRC in the {ctype.decode()} chunk")
    if ctype == b"IEND":
        break
    pos = end
print("chunk structure is valid")

Run against this file, it prints: truncated: the IDAT chunk needs 1252 bytes

Related guides and tools

Sample PNG fileFile signaturesMIME typesUpload validation checklistCheck a file's real typeVerify its SHA-256

Download & verify

curl -fsSL -o "png-truncated.png" "https://files.hexaqa.com/image/png-truncated.png"
curl -fsSL "https://files.hexaqa.com/image/png-truncated.png" | sha256sum # expect: 5442ebef90a3212ce5fec1b88eb613bcf13ea075d7974af9bdd09700f3f45514

More images test files

png-8000x8000.pngpng-alpha-gradient.pngpng-bad-crc.pngpng-interlaced.pngpng-valid-256.pngsvg-external-entity.svgsvg-plain.svgsvg-with-script.svg

← All Images files