What is Webp?
webp is one of the newest image format developed by Google. It combines the compression ability of jpegs with quality and transparency retention of PNG and allows us to make high quality transparent or non-transparent images that are very small.
WebP has significantly smaller file sizes than its alternatives even with all of these features and has been found to reduce the file size by almost 30%.
Major web browsers like Google Chrome natively support WebP while Mozilla has announced plans to implement WebP natively in Firefox.
Can I Use webp? Data on support for the webp feature across the major browsers from caniuse.com.
All graphics software like PhotoLine, Pixelmator, ImageMagick, XnView, IrfanView, GDAL and Aseprite all natively support WebP. Telegraphic has released a free plug-in that enables WebP support in Adobe Photoshop.
Converting images to webp format
To use WebP, first, you need to convert the existing images to webp format. There are various ways to convert images to webp format.
Online tools
www.squush.com – This is a website from Google from which you can convert your images to webp format. All you have to do is drag and drop an image and download the webp converted image.
Command-line tools
One of the popular command-line tools for converting images to webp format is the cwebp. We will be using the homebrew package manager to install cwebp in MAC OS cwebp is part of libwebp, and was written by the WebP team.
Homebrew is a package manager for MAC which can install lots of packages from the command line on Mac. It is the same as pip for python or yum for Linux.
To install homebrew type the below command in your terminal.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install
To know more about homebrew visit the Homebrew website
Once, homebrew is installed you can install cweb by typing brew install webp
Syntax:
cwebp [options] input_file -o output_file.webp
Usage:
After installation, We need to pass in options like the quality, input file, and output file for the command.Input file format can be either PNG, JPEG, TIFF, WebP or raw Y’CbCr.
Example:
cwebp -q 75 source.png -o output.webp
Using the MAC OS inbuilt Automator tool.
Automator is a tool in Mac Os which is designed to make the repetitive task much easier. To convert images to webp format we can use Automator which will allow us to convert the image with a single click instead of online or the command-line tool.
Please read more on – How to use Automator to save time
Initial Requirements:
The initial requirement is to have Cwebp installed and working.
Adding the lib to the path
To add the path in your ~/.bash_profile file and to do this, open the file typing the command sudo nano ~/.bash_profile. Then paste the below path in the file.
PATH=$PATH:"/usr/local/bin" export PATH
To convert images to another file type with Automator, follow these steps:
- Open Automator or choose File➪New from the menu.
- Click on Quick Actions and then click Choose.
- Drag the Workflow receives current type to “Image files” in “finder app”
- Select utilities from left pane and drag and drop the “Run shell script” action into the workflow.
- Select the shell from the drop-down as bin bash.
- Change “pass input as arguments.” and paste the below lines of code into the Run Shell Script box.
source ~/.bash_profile for FILE in "$@" do echo "coverting file: $FILE" EXT=${FILE##*.} QUALITY=85 # quality of output image (You can change this: 1-100) cwebp -q $QUALITY "$FILE" -o "${FILE/%.$EXT/.webp}" done
Save the workflow with the name that you want to show up in the context menu.
Now, test by Right-clicking on an image and convert it. You should see a new image generated within a second.
Leave a Reply