JBIG2
image/x-jbig2
Magic Bytes
Offset: 0
97 4A 42 32 0D 0A 1A 0A
JBIG2 is an image compression standard developed by the Joint Bi-level Image Experts Group under ISO/IEC specifically for bi-level imagery. It is primarily employed to store scanned documents and embedded images within PDF files, significantly reducing storage requirements for black-and-white text. Although generally considered safe for storage, complex parsing requirements have historically resulted in memory corruption vulnerabilities within specific decoder implementations.
Validation Code
How to validate .jbig2 files in Python
Python
def is_jbig2(file_path: str) -> bool:
"""Check if file is a valid JBIG2 by magic bytes."""
signature = bytes([0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A])
with open(file_path, "rb") as f:
return f.read(8) == signature
How to validate .jbig2 files in Node.js
Node.js
function isJBIG2(buffer: Buffer): boolean {
const signature = Buffer.from([0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A]);
return buffer.subarray(0, 8).equals(signature);
}
Go
func IsJBIG2(data []byte) bool {
signature := []byte{0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}
if len(data) < 8 {
return false
}
return bytes.Equal(data[:8], signature)
}
API Endpoint
GET
/api/v1/jbig2
curl https://filesignature.org/api/v1/jbig2