Detect PNG image header in data stream
Byte check header for the PNG header in a data stream
public static bool HasPngImageHeader(byte[] imageContents)
{
byte[] imageHeader = { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
return imageContents.Take(8).SequenceEqual(imageHeader);
}