Brother/Babylock/Bernina Home Embroidery file
application/octet-stream
Magic Bytes
Offset: 0
23 50 45 53 30
The PEC file format is a proprietary embroidery design format developed by Brother Industries and utilized by Babylock and Bernina sewing machines. These files contain stitch data and color information necessary for computer-controlled embroidery machines to reproduce digital patterns on various fabric types. Although largely superseded by the PES format, PEC remains a common legacy standard for home embroidery equipment and is generally considered low-risk for computer systems.
Validation Code
How to validate .pec files in Python
Python
def is_pec(file_path: str) -> bool:
"""Check if file is a valid PEC by magic bytes."""
signature = bytes([0x23, 0x50, 0x45, 0x53, 0x30])
with open(file_path, "rb") as f:
return f.read(5) == signature
How to validate .pec files in Node.js
Node.js
function isPEC(buffer: Buffer): boolean {
const signature = Buffer.from([0x23, 0x50, 0x45, 0x53, 0x30]);
return buffer.subarray(0, 5).equals(signature);
}
Go
func IsPEC(data []byte) bool {
signature := []byte{0x23, 0x50, 0x45, 0x53, 0x30}
if len(data) < 5 {
return false
}
return bytes.Equal(data[:5], signature)
}
API Endpoint
GET
/api/v1/pec
curl https://filesignature.org/api/v1/pec