CGM (.cgm)
.cgm file signature | image/cgm
Computer Graphics Metafile (CGM) is a vector graphics file format standardized by the International Organization for Standardization (ISO) for describing two-dimensional graphics. It is used for technical illustrations, engineering drawings, and interchange between CAD, publishing, and scientific visualization systems. CGM is a legacy format, and files from untrusted sources should be handled with normal caution because some viewers have historically supported embedded content.
Magic Bytes
Offset 0
42 45 47 4D 46
Sources: Apache Tika
All Known Signatures
2 signature variants are documented for .cgm files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 42 45 47 4D 46 | 0 | Apache Tika |
| 00 20 | 0 | Apache Tika |
Extension
.cgm
MIME Type
image/cgm
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .cgm files in 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
function isCGM(buffer: Buffer): boolean {
const signature = Buffer.from([0x42, 0x45, 0x47, 0x4D, 0x46]);
return buffer.subarray(0, 5).equals(signature);
}
How to validate .cgm files in 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
/api/v1/cgm
curl https://filesignature.org/api/v1/cgm
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .cgm file?
A .cgm file is identified by the magic bytes 42 45 47 4D 46 at byte offset 0. Computer Graphics Metafile (CGM) is a vector graphics file format standardized by the International Organization for Standardization (ISO) for describing two-dimensional graphics. It is used for technical illustrations, engineering drawings, and interchange between CAD, publishing, and scientific visualization systems. CGM is a legacy format, and files from untrusted sources should be handled with normal caution because some viewers have historically supported embedded content.
What are the magic bytes for .cgm files?
The magic bytes for CGM files are 42 45 47 4D 46 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .cgm file?
To validate a .cgm file, read the first bytes of the file and compare them against the known magic bytes (42 45 47 4D 46) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .cgm files?
The primary MIME type for .cgm files is image/cgm.
Is it safe to open .cgm files?
CGM (.cgm) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.