PBM
image/x-portable-bitmap
Magic Bytes
Offset: 0
50 31
The Portable Bitmap (PBM) format is a monochrome image format originally developed by Jef Poskanzer as part of the Netpbm open-source project. It serves as a lowest common denominator for exchanging black-and-white image data between various computer systems and graphics processing applications without requiring complex decompression algorithms. Although largely superseded by modern compressed formats, it remains a stable standard for basic graphics due to its human-readable structure and minimal security risk profile.
Validation Code
How to validate .pbm files in Python
Python
def is_pbm(file_path: str) -> bool:
"""Check if file is a valid PBM by magic bytes."""
signature = bytes([0x50, 0x31])
with open(file_path, "rb") as f:
return f.read(2) == signature
How to validate .pbm files in Node.js
Node.js
function isPBM(buffer: Buffer): boolean {
const signature = Buffer.from([0x50, 0x31]);
return buffer.subarray(0, 2).equals(signature);
}
Go
func IsPBM(data []byte) bool {
signature := []byte{0x50, 0x31}
if len(data) < 2 {
return false
}
return bytes.Equal(data[:2], signature)
}
API Endpoint
GET
/api/v1/pbm
curl https://filesignature.org/api/v1/pbm