Complete Guide to Using .WebP Image Format
WebP, or unofficially pronounced as weppy, is an image format introduced by Google Developers around 5 years ago. if you are a web designer, or a developer who strives to reduce and optimize your image file size, what WebP is capable of should put a smile on your face.
In brief, here are some of the important stuff you need to know about this not-so-new-but-still-cool image format:
- WebP goes by the file extension of .webp.
- WebP adopts both lossy and lossless compression.
- WebP lossy images are potentially 25-34% smaller than JPEG.
- WebP lossless images are potentially 25% smaller compared to PNG.
- WebP supports lossless transparency, i.e. PNG with alpha channel.
- WebP supports animation. i.e. animated GIFs.
In a nutshell, WebP is capable of significantly reducing JPEG, GIF, PNG’s image file size. Here’s a refresher on WebP you should check out before we go into the fun stuff.
The best things about claims on the Web is that we can always run experiments to check out the truthfulness and authenticity. Here are some experiments I did to find out how small an image can potentially get after they are converted from various image formats (JPEG, PNG and GIF) to WebP.
1. JPEG – Lossy Image
Here’s a random JPEG image I grabbed from Pexels. Original filesize – 165kb. ↓
Image is optimzed with JpegMini. New filesize – 101kb. ↓
Finally, the same image is converted to WebP format. Final filesize – 70kb. ↓
On a side note: Here are the different filesizes if the same image was converted to the following formats:
- GIF – 285kb
- PNG 8 – 241.2kb
- PNG 24 – 657.6kb
How to Save .WEBP Images as JPG and PNG
Google's proprietary image format WEBP is arguably better than the standard JPG or PNG format. It creates a... Read more
2. PNG – Lossless Image
Now, let’s try with PNG with transparency. (Source). Original filesize – 587kb. ↓
Here’s the image optimized with tinypng. New filesize – 278kb. ↓
And lastly, the image converted to WebP format. Final filesize – 112kb. ↓
3. Animated GIF
When converted to WebP, a JPEG image went from 165kb to 70kb, while a PNG image went from 587kb to 112kb.
Let’s see how an animated GIFs fare:
- Original filesize – 6.8mb
- WebP filesize – 6.3mb
Here’s a table to summarize the entire experiment:
|Lossy (JPG)||Lossless (PNG)||Animated-GIF|
|Optimized with tools||101kb||278kb||–|
Without dwelling much in mathematical calculations, those figures indicate substantial reduction of file sizes, and judging from the images, you can’t really tell the difference in terms of clarity and resolution. Smaller, lighter file sizes with the same level of image quality, WebP is definitely worth looking into.
Converting to WebP with Tools
If you’re already on board and would like to start releasing images in WebP format, let’s dive in and look at how you can convert your images easily to this format. All the methods mentioned below vary in terms of controls, ease to use, and conviniency. Pick your poison.
WebPonize for Mac
WebPonize is probably the simplest and fastest way to convert images to WebP format on the Mac. All you need to do is just drag and drop your images into WebPonize and it’ll do the conversion. You will receive the ouput, the before-size, after-size and the % of reduction of the original file. [Download WebPonize]
Webpconv for Windows
If you’re running Windows, Webpconv is the app you should install. It also comes in portable version so you can run it independently on your flash drive. [Download Webconv]
Converting with Command Lines
If you are feeling geeky, you may probably want to excute the conversion using command lines. cwebp converts your JPEG, PNG, or TIFF images into WebP format and dwebp converts them back to PNG format. Let’s see how this works.
Note: The following guide it for Mac OS X. For Windows and Linux users, click here.
Setting up MacPorts on Mac OSX
First up, make sure you have Xcode installed, then follow these steps:
- Download and install MacPorts. If you already have MacPorts installed in your Mac, proceed to step 2.
- Launch Terminal.
- Type "sudo port selfupdate" and hit enter. This will update your MacPorts to the latest version.
- Next, type "sudo port install webp" and hit enter. This will install libwebp (WebP Library).
That’s it. Now let’s take a look at how to convert images to WebP using command line.
Commands to Convert/Revert
Here are the commands to:
I – Convert JPEG / PNG image files to WebP format
Format: cwebp -q [image_quality] [JPEG/PNG_filename] -o [WebP_filename]
cwebp -q 80 example.png -o example.webp
II – Covert WebP image files back to PNG
Format: dwebp [WebP_filename] -o [PNG_filename]
dwebp image.webp -o image.png
More: If you perfer conversioni via other means, here are instructions for using Grunt and Gulp tasks to convert JPG/PNG files to WebP.
Convert With Online Tools
If you’re not looking at installing any applications on your operating system to perform this task, opt for these online tools instead. Here are a few that I’ve come to know:
Tip: If you google
convert webp online , you will probably find more options.
You may be glad to know that there is also a Photoshop Plugin that allows you to save images to WebP format via Photoshop. This plugin supports Mac OS X (CS 2- CS 6) and Windows (32 bit & 64 bit). [Download the plugin here.]
Note: Just thought you should know that I tried it on Photoshop CC. Didn’t work there.
WebP Browser Support
Lastly, let’s talk about compatibility. Currently, you can view WebP format images on the following browsers (ref):
- Chrome / Chrome for iOS
- Opera / Opera Mini
Fall back to other image formats
It’s always a good idea to use a fallback to avoid showing image errors due to unsupported browsers. In this case, the fallback will be to the image in JPG or PNG format. Here’s how you do it.
<picture> source srcset="example.webp 1x" type="image/webp"> <img src="example.jpg"> </picture>
For this code, example.jpg will be loaded if the user used Firefox or Safari.
Previewing WebP images
You can preview WebP images on Chrome and Opera browers. But if you want to do it locally on your machine, you will need a few tools.
Mac Users can use WebPQuickLook to preview WebP format images using the Quick Look function (with the image selected or highlighted, press the spacebar).
For Windows Users, WebPCodec will display a thumbnail preview of WebP images in File Explorer. Both the WebP and JPEG equivalents will be shown. On certain supported Window OS (Vista, 7, 8), the WebP image can be shown on the Windows Photo Viewer as well.
More: ReSCR.it delivers images in WeBP format automatically and it’s available if you store your images with MaxCDN. (Read more)