CGM

image/cgm

Safe

Magic Bytes

Offset: 0
42 45 47 4D 46

Computer Graphics Metafile (CGM) is an international standard maintained by ISO and IEC for the representation of 2D vector and raster graphics. It is widely utilized in technical fields such as aeronautics, engineering, and architectural design for exchanging complex CAD illustrations and high-precision diagrams between disparate computer systems. Although largely superseded by modern standards like SVG, CGM persists as a critical legacy format for industrial documentation and specialized scientific visualization due to its robust stability.

Extension

.cgm

MIME Type

image/cgm

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .cgm files in Python

Python
def is_cgm(file_path: str) -> bool:
    """Check if file is a valid CGM by magic bytes."""
    signature = bytes([0x42, 0x45, 0x47, 0x4D, 0x46])
    with open(file_path, "rb") as f:
        return f.read(5) == signature

How to validate .cgm files in Node.js

Node.js
function isCGM(buffer: Buffer): boolean {
  const signature = Buffer.from([0x42, 0x45, 0x47, 0x4D, 0x46]);
  return buffer.subarray(0, 5).equals(signature);
}
Go
func IsCGM(data []byte) bool {
    signature := []byte{0x42, 0x45, 0x47, 0x4D, 0x46}
    if len(data) < 5 {
        return false
    }
    return bytes.Equal(data[:5], signature)
}

API Endpoint

GET /api/v1/cgm
curl https://filesignature.org/api/v1/cgm

Related Formats