Manfaat Menggunakan Format WebP untuk Gambar Anda
Jelajahi manfaat format WebP untuk gambar Anda! Kurangi ukuran file, tingkatkan kecepatan situs web, dan tingkatkan pengalaman pengguna dengan format gambar modern ini.
Isi
WebP is not one image format. It is a RIFF container holding two completely different codecs — a lossy one derived from the VP8 video codec, and a lossless one called VP8L — plus optional alpha, animation frames and metadata. Almost every complaint about WebP ("it wrecks my logos", "it can't do transparency", "it looks worse than JPEG") comes from someone using the wrong one of those two codecs.
This guide covers what is actually inside a WebP file, what it realistically saves against JPEG and PNG, how to convert in both directions, how to serve it with a safe fallback, and — the part most WebP articles skip — when not to use it at all. WebP is supported in every current browser, but it is no longer automatically the best choice.
Everything below is checked against Google's WebP documentation and the RIFF container specification. Where a widely repeated figure does not survive that check, it is called out.
What is actually inside a WebP file
Open a .webp file in a hex editor and you see RIFF, a size, then WEBP. After that comes a chunk whose four-character code tells you which kind of WebP you hold.
Simple lossy WebP: the VP8 chunk
A basic lossy file contains a single chunk tagged "VP8 " (with a trailing space) — a still frame of the VP8 video codec, 8-bit Y'CbCr with 4:2:0 chroma subsampling. That subsampling is the single most important fact about lossy WebP: colour is stored at half resolution in both directions, exactly as in most JPEGs, which is why lossy WebP is excellent for photographs and poor for sharp saturated edges like red text on white.
Lossless WebP: the VP8L chunk
A lossless file contains a VP8L chunk instead. VP8L is a genuinely different algorithm from VP8: it works on 8-bit ARGB at 32 bits per pixel and applies reversible transforms — spatial prediction, colour decorrelation, colour indexing for palette images, and backward reference matching — before entropy coding. It competes directly with PNG's DEFLATE and wins on almost every realistic input. VP8L carries alpha natively, so it needs no separate transparency chunk.
The extended format: VP8X
Anything beyond a plain still — transparency on a lossy image, animation, an ICC profile, Exif or XMP metadata — needs a VP8X header chunk at the front, carrying six one-bit feature flags: ICC profile, alpha, Exif, XMP, animation, and one reserved bit. VP8X stores canvas width and height as 24-bit values, which is why people sometimes claim WebP handles images 16 million pixels wide. It does not, for the reason two sections down.
Transparency and the ALPH chunk — where Google's own FAQ is wrong
This is the most persistent piece of WebP misinformation online, and Google's own WebP FAQ repeats it — still stating that lossy WebP "works exclusively with an 8-bit Y'CbCr 4:2:0 image format" and that only lossless WebP supports alpha. That text is out of date.
The RIFF container specification is unambiguous: the ALPH chunk "contains encoded alpha data for this frame", and a frame containing a VP8L chunk should not contain it — because ALPH exists precisely to add alpha to a lossy VP8 frame. ALPH stores the alpha data separately from the colour data, either raw or compressed with WebP lossless coding, so the transparency mask stays crisp while the colour underneath is compressed lossily. The encoder confirms it: cwebp has an -alpha_q option (0–100, default 100 for lossless alpha) that only makes sense on a lossy encode.
The consequence is large: a product cut-out with a transparent background does not need lossless encoding to keep its transparency, and lossy-with-alpha is often several times smaller than lossless WebP for the same image. If a tutorial told you lossy WebP can't do alpha, it was wrong.
Animation: ANIM and ANMF
An animated WebP uses a VP8X header with the animation flag set, a global ANIM chunk for background colour and loop count, and one ANMF chunk per frame carrying offset, dimensions, duration and disposal method. Each frame can independently be lossy or lossless and carry its own alpha, making animated WebP a strictly better container than GIF and its 256-colour palette and 1-bit transparency. Beyond a couple of seconds, a muted autoplaying MP4 or WebM beats both.
The real dimension limit: 16383 × 16383
WebP cannot exceed 16,383 pixels in either direction. The VP8 bitstream stores width and height in 14 bits each, and 2^14 − 1 = 16,383; the container's 24-bit canvas fields are irrelevant because the codec caps you first. Encoders simply refuse oversized input. That matters for panoramas, scanned drawings, gigapixel maps and tall stitched screenshots. AVIF and JPEG XL have no practical ceiling and plain JPEG goes to 65,535 per side, so any of those is a better home for an outsized image. If your source is only slightly over, scale it down first with an image resizer.
What WebP realistically saves
Marketing copy is full of "up to 50%" claims. Here are Google's own published figures and what they mean.
| Claim | Google's published figure | What it actually means |
|---|---|---|
| Lossy WebP vs JPEG | ~30% average further compression at equivalent quality (WebP Lossy Study) | Measured against libjpeg at matched SSIM. Against a modern, well-tuned JPEG encoder the gap narrows considerably. |
| Lossless WebP vs PNG | ~26% smaller (WebP Lossless and Alpha Study) | Measured against PNGs as found in the wild. Against an already-optimised PNG the margin shrinks, though WebP usually still wins. |
| "Up to 34% smaller than PNG" | Not a Google figure | Circulates widely, does not match Google's published 26%. Marketing, not measurement. |
Expect a meaningful but not dramatic win over JPEG, a solid win over unoptimised PNG, and a very large win when the source is a photograph mistakenly saved as PNG — extremely common, and where the gain comes from finally using a photographic codec on photographic content. Never quote a percentage you have not measured yourself.
Conversion is no substitute for the basics either. Serving a 4000-pixel image into a 400-pixel slot wastes far more bytes than any codec choice recovers, so resize before encoding and run an image compressor pass over anything you are not hand-tuning.
Format capability comparison
| Capability | JPEG | PNG | WebP | AVIF |
|---|---|---|---|---|
| Lossy compression | Yes | No | Yes (VP8) | Yes (AV1) |
| Lossless compression | No (in practice) | Yes | Yes (VP8L) | Yes |
| Alpha transparency | No | Yes | Yes, lossy and lossless | Yes |
| Animation | No | No (APNG only) | Yes | Yes |
| Bit depth | 8-bit | Up to 16-bit per channel | 8-bit only | 8, 10 or 12-bit |
| HDR / wide gamut | No | Limited | No | Yes |
| Progressive rendering | Yes | Interlacing | Yes | No |
| Max dimensions | 65,535 per side | Effectively unlimited | 16,383 per side | Effectively unlimited |
Two rows decide most real arguments: WebP is 8-bit only, so no HDR and no 16-bit master, and it caps at 16,383 pixels.
How to convert JPG images to WebP
JPG to WebP is the easy direction: the source is already lossy and photographic, so you want lossy WebP and no alpha. Understand generation loss first — a JPEG has already thrown data away, and re-encoding as lossy WebP throws away more. Convert from the highest-quality original you have, not a JPEG through three previous saves.
Method 1: a browser-based converter
For a handful of files, a browser-based JPG to WebP converter is fastest.
- Keep the originals safe — conversion is not meaningfully reversible, since you cannot recover what a lossy encoder discarded.
- Resize first if the image is larger than you will ever display it; scaling a huge file down in CSS wastes bandwidth on every page view.
- Upload the files and convert, then compare the output sizes against the originals. If a WebP is larger than its JPG source, the JPG was already heavily compressed — keep the JPG.
- View the result at full size before shipping — faces, skies and gradients show artefacts first — then update your markup with a fallback in place.
Method 2: the cwebp command line
For volume, use Google's own encoder, cwebp, from libwebp. It is the reference implementation and exposes every knob the format has:
| Option | Default | What it does |
|---|---|---|
| -q float | 75 | Lossy quality factor, 0–100. |
| -lossless | off | Use the VP8L codec instead of VP8. |
| -near_lossless int | 100 | Lossless preprocessing; lower values allow small targeted losses to improve compression. |
| -z int | — | Lossless shorthand, speed/size levels 0–9. |
| -alpha_q int | 100 | Alpha quality, 0–100; 100 is lossless alpha. |
| -m int | 4 | Method 0–6; higher is slower and smaller. |
| -mt | off | Enable multi-threading. |
| -resize w h | — | Resize during encoding; pass 0 for one dimension to keep aspect ratio. |
| -metadata string | none | Metadata to copy: all, none, exif, icc, xmp. |
A sensible starting point for a photograph:
cwebp -q 80 -m 6 -mt -metadata icc photo.jpg -o photo.webp
Quality 80 with method 6 is a good default: better than the default 75 at a small size cost, with method 6 buying compression at the price of encoder time you pay once. Note -metadata defaults to none — cwebp silently strips Exif, ICC and XMP unless asked. Usually fine, but if your images are not sRGB, pass -metadata icc or colours will shift. For a whole folder:
for f in *.jpg; do cwebp -q 80 -m 6 -mt "$f" -o "${f%.jpg}.webp"; done
Method 3: graphics editors
Photoshop, GIMP and Affinity Photo all export WebP directly — in GIMP, File > Export As with a .webp extension opens a dialog exposing quality, the lossless toggle and alpha quality. Editors suit hand-tuning a hero image and not volume. ImageMagick and FFmpeg also write WebP, useful inside a longer pipeline.
How to convert PNG images to WebP
PNG to WebP is where people get it wrong, because the answer depends entirely on what is in the PNG. Sort into two piles first.
Pile one: flat graphics, logos, icons, screenshots of text
Large areas of identical colour and hard edges. Use lossless WebP — VP8L's colour-indexing and predictor transforms are built for exactly this, and you get a smaller file with pixel-identical output.
cwebp -lossless -z 9 logo.png -o logo.webp
Pile two: photographs and photographic cut-outs saved as PNG
These are the big wins. A photograph stored as PNG is enormously wasteful, and switching to lossy WebP typically cuts the file dramatically. If it has a transparent background, use lossy with alpha — which, as established above, WebP fully supports despite the FAQ.
cwebp -q 80 -alpha_q 100 product-cutout.png -o product-cutout.webp
That gives a lossily-compressed colour image with a losslessly-compressed alpha mask — almost always right for a product shot on a transparent background.
The step-by-step PNG workflow
- Separate flat graphics from photographic content: smooth gradients and noise mean photographic, flat fills and hard edges mean graphic.
- Strip the PNG first — remove editor metadata and drop the bit depth if it does not need 16 bits per channel. A cleaner source encodes better.
- Resize to the maximum size you will actually display.
- Encode flat graphics with -lossless and photographs at -q 75 to -q 85. Without a terminal, the PNG to WebP converter handles both cases.
- Compare against the original at 100% zoom, watching edges, text and semi-transparent pixels around a cut-out.
- If lossless WebP came out larger than the optimised PNG — which happens with very small or heavily palettised images — keep the PNG. No rule says every file must be WebP.
Going the other way — a print workflow, or a tool that refuses WebP — the WebP to PNG converter restores a transparency-preserving format, the WebP to JPG converter flattens for JPEG-only systems, and WebP to PDF assembles images into a document directly.
Serving WebP safely with a fallback
You have two good options, and one habit worth breaking.
The picture element. Wrap the image in <picture>, list WebP (and optionally AVIF) sources with explicit type attributes, and put a JPEG or PNG in the inner <img>. The browser takes the first type it understands. Pure markup, needs nothing from your server.
Content negotiation. Browsers that support WebP advertise image/webp in their Accept header, so a server or CDN can return WebP from the same URL and vary the response on Accept. This is how most image CDNs work, but set the Vary header correctly or intermediate caches will hand WebP to clients that cannot render it.
The habit to break is user-agent sniffing. Both mechanisms above ask the browser what it supports instead of guessing from a version list that goes stale.
Keep your alt text intact through the migration — format swaps are exactly when alt attributes get dropped by a sloppy find-and-replace, and an image alt text checker finds the ones you missed. For tiny inline assets, a data URI from an image to Base64 tool removes a request, though Base64 adds roughly a third to the byte size.
Browser support today
| Browser | WebP still images | Animated WebP | AVIF |
|---|---|---|---|
| Chrome | Since 17 | Since 32 | Since 85 |
| Firefox | Since 65 | Since 65 | Since 93 (animation since 113) |
| Edge | Since 18 | Since 18 | Since 121 |
| Safari (macOS/iOS) | Since 14 (macOS Big Sur or later) | Since 14 | Since 16.1 |
| Opera | Since 11.10 | Since 19 | Since 71 |
WebP works in every current version of every major browser. The Safari 14 cut-off is the historical sticking point: Safari lagged by years, and Safari 14 also requires macOS Big Sur, so an old Mac that cannot run Big Sur cannot display WebP in Safari at all. That population is small enough for a picture-element fallback to cover — which is the reason to keep the fallback rather than delete your JPEGs.
Outside browsers, support is patchier: some email clients, older CMS media libraries and desktop applications still choke on WebP. Convert web delivery copies only, never your archival originals.
WebP versus AVIF versus JPEG XL
This is where older advice is genuinely out of date. WebP was the only modern option for a decade; it is not any more.
| WebP | AVIF | JPEG XL | |
|---|---|---|---|
| Underlying codec | VP8 / VP8L | AV1 intra frame | Purpose-built still-image codec |
| Compression at equal quality | ~30% better than JPEG | Roughly 50% better than JPEG on the same test set | Competitive with or ahead of AVIF, especially at high quality |
| Browser support | Universal | All major browsers | Safari 17+; not enabled by default in Chrome or Firefox |
| Bit depth / HDR | 8-bit, no HDR | Up to 12-bit, HDR and wide gamut | High bit depth, HDR |
| Progressive rendering | Yes | No | Yes |
| Encode speed | Fast | Noticeably slower | Fast |
| Lossless JPEG recompression | No | No | Yes |
AVIF is the better compressor and is now supported across all major browsers. Its weaknesses are narrow: encoding is slow, there is no progressive rendering so a large AVIF shows nothing until fully downloaded, and it can smear fine texture at low quality. For large hero photography, AVIF usually wins.
JPEG XL is technically excellent and practically stalled. Safari 17 ships it; Chrome and Firefox do not enable it by default. Its standout feature — losslessly and reversibly recompressing an existing JPEG archive to a meaningfully smaller file — is genuinely valuable, but you cannot rely on it for public web delivery today.
WebP's remaining advantage is that it is boring: universal support, fast encoding, good-enough compression, progressive rendering, and one format covering lossy, lossless, alpha and animation. The strongest setup is AVIF, then WebP, then a JPEG or PNG fallback in a picture element. If you can ship only one modern format, WebP is still the safest choice.
When not to use WebP
Converting everything to WebP is a mistake. Skip it when:
- The image exceeds 16,383 pixels on a side. The format simply cannot hold it.
- You need more than 8 bits per channel, HDR or a wide gamut. WebP is 8-bit only. Use AVIF, JPEG XL or a 16-bit PNG/TIFF master.
- The file is an archival master or print deliverable. Convert delivery copies, never your source of truth.
- The destination is email, a print shop or a third-party system. Support there is still patchy — send JPEG or PNG.
- The image is a vector shape — logo, icon, chart. SVG is resolution-independent, usually smaller and crisp at any size. No raster format beats it.
- The file is already tiny. Below a few kilobytes, container overhead can make the WebP larger. Measure, then decide — and if a converted JPEG comes out bigger, keep the JPEG.
- Exact pixel values matter for scientific, medical or legal reasons. Use lossless WebP if anything, and checksum the decoded output.
WebP and SEO: what is actually true
WebP is not a ranking factor; Google does not reward a file extension. The true version is narrower: image weight is a large part of Largest Contentful Paint, LCP is a Core Web Vital, and page experience acts as a tiebreaker among comparably relevant results. Cutting image bytes improves LCP, and that can help — indirectly, modestly, and only if your content is already competitive.
That tells you where to stop. Converting the image that is your LCP element is worth real effort; converting a lazy-loaded icon below the fold is worth almost nothing. Find out which images block your largest paint before a site-wide migration, and re-measure afterwards with a page speed analyzer.
Google Images indexes WebP normally, so there is no discovery penalty. Just make sure file names, alt text, structured data and image sitemaps survive — those genuinely affect image search, and are what a bulk conversion script tends to break.
Practical tips that actually move the needle
- Resize before you encode. Dimension reduction beats codec choice every time; serve responsive sizes with srcset.
- Use quality 75–85 for photography. Above 90 the file grows fast for gains nobody sees; below 70 artefacts show on skin and sky.
- Use method 6 for anything encoded once and served endlessly. Encoder time is cheap; bandwidth is not.
- Pass -metadata icc if your images are not sRGB, because cwebp strips metadata by default.
- Lazy-load below-the-fold images — but never your LCP image; lazy-loading that one makes the page slower.
- Serve through a CDN. Distance costs more milliseconds than most codec differences save.
- Keep the originals so a botched conversion can be redone from a source.
- Convert opportunistically. Sort by file size, fix the worst offenders, measure, repeat.
Where WebP is not the target, the same discipline applies to whatever you pick instead: a PNG to JPG converter for a photograph wrongly saved as PNG that must stay universally supported, and a JPG to PNG converter when a downstream tool demands lossless input.
Frequently asked questions
Does lossy WebP support transparency?
Yes. A lossy VP8 frame carries transparency in a separate ALPH chunk, exposed by the encoder's -alpha_q option. Google's own WebP FAQ still says otherwise; the RIFF specification and the encoder documentation both contradict it. Lossy-with-alpha is usually best for photographic images on a transparent background.
What is the maximum size of a WebP image?
16,383 pixels in either direction: the VP8 bitstream allocates 14 bits per dimension, and 2^14 − 1 = 16,383. Encoders reject anything larger.
Is WebP better than JPEG?
Usually, by roughly 30% at equivalent quality per Google's own study — though that compares against libjpeg, and a well-tuned modern JPEG encoder closes much of the gap. WebP also gives you transparency and animation, which JPEG cannot. For pure photographic compression, AVIF beats both.
Should I use WebP or AVIF?
Both, via a picture element: AVIF first, WebP second, JPEG or PNG as fallback. If you must pick one, AVIF compresses better while WebP encodes faster and renders progressively. Hero images, AVIF; site-wide default, WebP.
Will converting my images to WebP improve my Google rankings?
Not directly — WebP is not a ranking signal. Smaller images improve LCP, a Core Web Vital, and page experience acts as a tiebreaker between comparably relevant pages. The effect is real but indirect, and applies only to images actually slowing your page down.
Can I convert WebP back to JPG or PNG?
Yes, and it decodes correctly — but you cannot recover data lossy compression discarded. Converting lossy WebP back to PNG gives a large file identical to the compressed version, not the original. Keep your originals.
Does WebP replace GIF for animation?
For short loops, yes: animated WebP supports full colour and proper alpha where GIF is stuck at 256 colours and 1-bit transparency, and the files are far smaller. Beyond a couple of seconds, a muted autoplaying MP4 or WebM beats both.
Why is my WebP file bigger than the original?
Three common causes: the source was an already heavily compressed JPEG; you used lossless mode on a photograph, the wrong codec for it; or the file is small enough that container overhead dominates. If none applies, keep the original.
The short version
WebP is a container holding two codecs. Use lossy VP8 for photographs, lossless VP8L for flat graphics, and lossy-plus-ALPH for photographic images that need transparency — that last combination works despite what Google's FAQ says. Expect around 30% off JPEG and around 26% off PNG on average rather than the inflated marketing figures, and measure on your own images. Remember the 16,383-pixel cap and the 8-bit ceiling, and keep a fallback in a picture element. WebP is now the reliable middle option rather than the frontier: AVIF compresses better, JPEG XL is technically stronger but practically stalled, and WebP wins on simply working everywhere, every time.
The UrwaTools Editorial Team delivers clear, practical, and trustworthy content designed to help users solve problems efficiently. Our articles focus on accurac...