XPM
application/octet-stream
Magic Bytes
Offset: 0
2F 2A 20 58 50 4D 20 2A 2F
The X PixMap (XPM) is an ASCII-based image format created in 1989 by Daniel Dardailler and Colas Nahaboo at the Bull Research Center. Primarily utilized within the X Window System, it serves to store icon pixmaps with transparency support and is designed to be included directly in C source code. Although largely superseded by modern formats, it remains a stable standard that presents minimal security risks because it lacks executable content or complex compression algorithms.
Validation Code
How to validate .xpm files in Python
Python
def is_xpm(file_path: str) -> bool:
"""Check if file is a valid XPM by magic bytes."""
signature = bytes([0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A, 0x2F])
with open(file_path, "rb") as f:
return f.read(9) == signature
How to validate .xpm files in Node.js
Node.js
function isXPM(buffer: Buffer): boolean {
const signature = Buffer.from([0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A, 0x2F]);
return buffer.subarray(0, 9).equals(signature);
}
Go
func IsXPM(data []byte) bool {
signature := []byte{0x2F, 0x2A, 0x20, 0x58, 0x50, 0x4D, 0x20, 0x2A, 0x2F}
if len(data) < 9 {
return false
}
return bytes.Equal(data[:9], signature)
}
API Endpoint
GET
/api/v1/xpm
curl https://filesignature.org/api/v1/xpm