GoogleWebP image file
image/webp
Magic Bytes
Offset: 0
52 49 46 46 2E 2E 2E 2E 57 45 42 50
The WebP image format is a raster graphics standard developed by Google to provide efficient data compression for web imagery. It supports both lossy and lossless compression, including transparency and animation, making it a standardized alternative to the JPEG, PNG, and GIF formats. Although generally considered safe, vulnerabilities in the underlying libwebp library have historically required security updates across web browsers, image viewers, and various operating systems.
Validation Code
How to validate .webp files in Python
def is_webp(file_path: str) -> bool:
"""Check if file is a valid WEBP by magic bytes."""
signature = bytes([0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x45, 0x42, 0x50])
with open(file_path, "rb") as f:
return f.read(12) == signature
How to validate .webp files in Node.js
function isWEBP(buffer: Buffer): boolean {
const signature = Buffer.from([0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x45, 0x42, 0x50]);
return buffer.subarray(0, 12).equals(signature);
}
How to validate .webp files in Go
func IsWEBP(data []byte) bool {
signature := []byte{0x52, 0x49, 0x46, 0x46, 0x2E, 0x2E, 0x2E, 0x2E, 0x57, 0x45, 0x42, 0x50}
if len(data) < 12 {
return false
}
return bytes.Equal(data[:12], signature)
}
API Endpoint
/api/v1/webp
curl https://filesignature.org/api/v1/webp
Related Formats
Frequently Asked Questions
What is a .webp file?
A .webp file is a GoogleWebP image file file. The WebP image format is a raster graphics standard developed by Google to provide efficient data compression for web imagery. It supports both lossy and lossless compression, including transparency and animation, making it a standardized alternative to the JPEG, PNG, and GIF formats. Although generally considered safe, vulnerabilities in the underlying libwebp library have historically required security updates across web browsers, image viewers, and various operating systems.
What are the magic bytes for .webp files?
The magic bytes for GoogleWebP image file files are 52 49 46 46 2E 2E 2E 2E 57 45 42 50 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .webp file?
To validate a .webp file, read the first bytes of the file and compare them against the known magic bytes (52 49 46 46 2E 2E 2E 2E 57 45 42 50) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .webp files?
The primary MIME type for .webp files is image/webp.
Is it safe to open .webp files?
GoogleWebP image file (.webp) 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.