SVGZ
image/svg+xml
Magic Bytes
Offset: 0
3C 73 76 67
Compressed Scalable Vector Graphics (SVGZ) is a variant of the standard SVG format developed and maintained by the World Wide Web Consortium (W3C). This format is utilized in web development and graphic design to deliver complex vector imagery while significantly reducing bandwidth consumption through GZIP compression. While generally considered safe for static imagery, the underlying XML can contain embedded scripts, necessitating robust sanitization during processing to mitigate potential cross-site scripting risks.
Validation Code
How to validate .svgz files in Python
Python
def is_svgz(file_path: str) -> bool:
"""Check if file is a valid SVGZ by magic bytes."""
signature = bytes([0x3C, 0x73, 0x76, 0x67])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .svgz files in Node.js
Node.js
function isSVGZ(buffer: Buffer): boolean {
const signature = Buffer.from([0x3C, 0x73, 0x76, 0x67]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsSVGZ(data []byte) bool {
signature := []byte{0x3C, 0x73, 0x76, 0x67}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/svgz
curl https://filesignature.org/api/v1/svgz