Insipration

Block Heap

Web Developer's Blog

Encode images in modern webp format

We’ll be using the libwebp library from the WebM Project to create compressed webp images.

The WebM Project is dedicated to developing a high-quality, open video format for the web that’s freely available to everyone.

We’re assuming the following:

*You may refer to this article for alternative installation instructions.


Install webp


    brew install webp

Basic Commands

Options with descriptions


    cwebp -longhelp

Lossy quality setting (75 is default)


    cwebp -q 50 source.jpg -o output.webp

Alpha transparency quality (100 default)


    cwebp -alpha_q 10 source.png -o output.web

Batch Processing

I’ve written a simple bash script to make things easier on msyelf.

Usage:

1. Download the packaged files and extract in a convenient spot

2. Place your files into the ‘images’ directory

 

3. Open the terminal and CD into the ‘cwebp-cli’ directory, which will obviously vary based on where you put it. Here’s mine:


cd ~/Desktop/cwebp-cli

4. Run the script


sh cwebp-cli.sh

5. Done! Your webp files can now be found in the ‘encoded’ directory


Related Articles

Example Source Files

Leave a Reply

Your email address will not be published.

SIDEBAR HERE