Windows graphics metafile
image/wmf
Magic Bytes
Offset: 0
D7 CD C6 9A
Windows graphics metafile (WMF) is a legacy format originally developed by Microsoft for the Windows operating system to store vector and bitmap images. It was primarily utilized for transferring graphical data between different applications and served as the native vector format for early versions of Microsoft Office and Windows clipboard operations. Although largely superseded by the Enhanced Metafile (EMF) format, it remains supported for backward compatibility despite historical security vulnerabilities associated with its ability to execute embedded function calls.
Validation Code
How to validate .wmf files in Python
Python
def is_wmf(file_path: str) -> bool:
"""Check if file is a valid WMF by magic bytes."""
signature = bytes([0xD7, 0xCD, 0xC6, 0x9A])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .wmf files in Node.js
Node.js
function isWMF(buffer: Buffer): boolean {
const signature = Buffer.from([0xD7, 0xCD, 0xC6, 0x9A]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsWMF(data []byte) bool {
signature := []byte{0xD7, 0xCD, 0xC6, 0x9A}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/wmf
curl https://filesignature.org/api/v1/wmf