Google Web Picture Format (.webp)

RFC 标准

WebP is a modern image format developed by Google that provides superior lossless and lossy compression for web images, supporting both alpha transparency and animated frames.

将 JPG 转换为 WEBP

免费的浏览器端 JPG 转 WEBP 转换器。在您的设备上即时转换文件。

在线压缩 WebP

100% 浏览器本地私密压缩 — 文件永不离开您的设备

检查与元数据

操作系统和文件分析器通过检查开头的二进制字节序列来识别 WebP 文件:

选择或拖放文件

选择或将文件拖放到此处

100% 浏览器端私密转换 - 文件绝不会离开您的设备

或粘贴 Ctrl+V
零网络传输隐私保证: 上传至外部服务器的数据为 0 字节。所有处理均在您的浏览器沙箱中本地完成。

字节级文件头签名 (Magic Bytes)

操作系统和文件分析器通过检查开头的二进制字节序列来识别 WebP 文件:

十六进制签名 (偏移量 0):

52 49 46 46

ASCII 表示形式: RIFF

标准化: RFC 6386 / RIFF Container Specification

技术规格

容器架构Resource Interchange File Format (RIFF) container with 'WEBP' FourCC
压缩方式Lossy VP8 predictive intra-frame coding & Lossless VP8L spatial entropy coding
字节序Little-Endian for RIFF chunk sizes and container tags
色彩空间sRGB, Embedded ICC Profiles (via VP8X extended header)
通道与结构RGB + Alpha (8-bit per channel)
最大尺寸16,383 x 16,383 pixels (14-bit unsigned integers)
透明度Full 8-bit alpha channel transparency in both lossy and lossless modes
流式传输与渐进式加载Progressive decoding supported via incremental VP8 block decoding

技术对比矩阵:WebP 对比同类产品

技术属性WebP (当前)JPEGPNGAVIF
Supported Compression ModesBoth Lossy (VP8) and Lossless (VP8L)Lossy onlyLossless onlyBoth Lossy (AV1) and Lossless
Alpha TransparencyYes (both lossy and lossless)NoYesYes
Animation SupportYes (multi-frame with frame delays)NoRequires APNG extensionYes (AVIF image sequences)
HDR / Wide Color Gamut8-bit sRGB only8-bit standard8-bit & 16-bit10-bit & 12-bit native HDR
Browser Support97%+ global support across all modern browsers100% universal100% universal93%+ modern browsers

常见损坏模式与十六进制恢复指南

⚠️ Browser fails to display WebP image or shows broken image icon.

根本原因: RIFF payload length header (bytes 4-7) does not match the actual byte length on disk.

恢复方法: Recalculate total file size minus 8 bytes, and patch the 4-byte Little-Endian unsigned integer at offset 0x04.

⚠️ Decoder fails with 'Invalid FourCC: Expected WEBP'.

根本原因: Bytes 8-11 do not contain the ASCII characters 'WEBP'.

恢复方法: Verify offset 0x08 contains 0x57 0x45 0x42 0x50 ('WEBP') and that the chunk header matches 'VP8 ' or 'VP8L'.

安全分析与解析器攻击向量

WebP parsing gained intense security scrutiny following CVE-2023-4863, leading to widespread sandbox hardening across all major web browsers.

已知攻击向量

  • CVE-2023-4863: Heap buffer overflow in libwebp's BuildHuffmanTable function when parsing invalid lossless Huffman tables, allowing remote code execution.
  • Integer overflow when decoding oversized animation frame canvas dimensions.

防御性最佳实践: Ensure all client and server libraries use libwebp 1.3.2 or later. Decode WebP files in memory-sandboxed worker threads.

历史渊源与里程碑

2020Apple Safari 14 adds native WebP support, achieving 100% universal major browser coverage.
2012WebP adds lossless compression (VP8L), alpha channel transparency, and animation.
2010Google releases WebP as an open-source image format to accelerate web performance.

核心优势与特点

  • Lossy WebP images are 25%–35% smaller than comparable JPEG images at identical SSIM quality.
  • Lossless WebP is typically 26% smaller than standard PNG.
  • Single unified format handles photos, graphics with transparency, and lightweight animated clips.

技术局限与劣势

  • Maximum dimensions capped at 16,383 x 16,383 pixels, preventing ultra-high resolution panoramic imagery.
  • Only supports 8-bit color depth (no native 10-bit or 12-bit HDR support).
  • Encoding complex lossy images requires more CPU cycles than legacy JPEG encoders.

趣味技术冷知识

  • WebP is based on the keyframe intra-prediction algorithms of Google's open-source VP8 video codec.
  • The RIFF container used by WebP is the exact same container architecture used by classic Microsoft AVI and WAV files.
  • Animated WebP files are typically 60%–80% smaller than animated GIFs.

常见技术问题

Can WebP completely replace both PNG and JPEG?

Yes. For web use, WebP provides superior compression for both photographic content (replacing JPEG) and transparent graphics (replacing PNG). Its universal browser support makes it a primary format for modern web optimization.

Why is WebP lossless compression more efficient than PNG?

WebP lossless uses advanced spatial predictors, color transform decorrelation, a localized color cache, and entropy-coded 2D transforms, resulting in files that are typically 26% smaller than optimal PNGs.

Does WebP support animation?

Yes. WebP supports multi-frame animation with variable frame delays, full alpha transparency per frame, and disposal methods, delivering 60%–80% smaller payloads than traditional animated GIFs.