PPM
image/x-portable-pixmap
Magic Bytes
Offset: 0
50 33
The Portable Pixmap (PPM) is a cross-platform color image format originally developed by Jef Poskanzer as part of the Netpbm project. It serves as a common intermediate representation for converting images between different formats and is frequently used in computer graphics education due to its simple structure. This legacy format is considered inherently safe because it lacks support for metadata, complex compression algorithms, or executable scripts that could facilitate malicious activity.
Validation Code
How to validate .ppm files in Python
Python
def is_ppm(file_path: str) -> bool:
"""Check if file is a valid PPM by magic bytes."""
signature = bytes([0x50, 0x33])
with open(file_path, "rb") as f:
return f.read(2) == signature
How to validate .ppm files in Node.js
Node.js
function isPPM(buffer: Buffer): boolean {
const signature = Buffer.from([0x50, 0x33]);
return buffer.subarray(0, 2).equals(signature);
}
Go
func IsPPM(data []byte) bool {
signature := []byte{0x50, 0x33}
if len(data) < 2 {
return false
}
return bytes.Equal(data[:2], signature)
}
API Endpoint
GET
/api/v1/ppm
curl https://filesignature.org/api/v1/ppm