Does a Base64 string starting with iVBOR contain a PNG?
Compare the eight-byte PNG signature with a complete 8 × 8 image. Both have a recognizable start, but only one can display pixels.
Check the first eight decoded bytes
Every PNG begins with the signature below. The second line encodes just those eight bytes. In a complete file, the next byte shares the last Base64 group with the signature, so searching for the entire padded string in an image can miss a real PNG.
Restore the signature and then the sample
Decoding the short value yields an eight-byte fragment with no dimensions or pixels. Download the sample Base64 text file below and run it through file decoding. The restored sample is 81 bytes long and displays an 8 × 8 checkerboard.
89 50 4E 47 0D 0A 1A 0A
iVBORw0KGgo=Investigate an image that still will not open
After the signature, a PNG needs chunks including IHDR for image information, IDAT for image data and IEND at the end. A truncated copy can pass the signature check. Compare the full byte count and checksum with the source before changing the extension.