JB2
image/x-jbig2
Magic Bytes
Offset: 0
97 4A 42 32 0D 0A 1A 0A
JB2 refers to the raw bitstream of the JBIG2 standard, a bi-level image compression format developed by the Joint Bi-level Image Experts Group under ISO/IEC. It is primarily utilized for efficiently compressing black-and-white scanned documents, offering significantly higher compression ratios than predecessors like CCITT Group 4. While often embedded directly within PDF files to reduce document size, standalone JB2 streams allow for specialized decoding in archival workflows.
Validation Code
How to validate .jb2 files in Python
Python
def is_jb2(file_path: str) -> bool:
"""Check if file is a valid JB2 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 .jb2 files in Node.js
Node.js
function isJB2(buffer: Buffer): boolean {
const signature = Buffer.from([0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A]);
return buffer.subarray(0, 8).equals(signature);
}
Go
func IsJB2(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/jb2
curl https://filesignature.org/api/v1/jb2