How to Batch Convert Images to WebP on Mac
As WebP grows in reputation as a compressed picture format for the net, many internet staff have to convert batches of photographs to WebP format from their Mac. Bulk changing photographs like JPG and PNG to WebP shouldn’t be at present a local function, however with a little bit tinkering on the Mac, you possibly can acquire performance to simply batch convert any photographs to WebP on the Mac.
This text is increasing on this put up about changing photographs to webp utilizing the Mac command line. We’ll be utilizing the identical webp toolkit from Google that’s put in by means of HomeBrew, so that you’ll wish to set up HomeBrew first, then set up the webp instruments from Google through Homebrew so that you’ve got cwebp out there as a command line utility in your Mac. However you gained’t want to make use of the command line past the preliminary set up, as a result of we’ll be utilizing Automator to create a Finder Fast Motion that performs the picture compression and conversions to webp.
Easy methods to Batch Convert Pictures to WebP on Mac with a Fast Motion
We’re going to create a Fast Motion with Automator that makes use of the command line cwebp instrument to transform picture recordsdata to webp format. The result’s you should have an contextual menu choice to ‘Convert to WebP’ within the Finder, that you need to use with any picture file or assortment of picture recordsdata on the Mac.
-
- Set up HomeBrew and cwebp you probably have not performed so already (instructions to put in Homebrew are right here, and to put in cwebp are right here)
- Open Automator on the Mac
- Create a brand new “Fast Motion”
-
- On the high of the Workflow, the place it says “Workflow receives present” select “picture recordsdata”, and beneath “in” choose “Finder”
-
- Subsequent, have a look at the left facet panel of Automator and select “Utilities” beneath Library, then drag and drop “Run Shell Script” to the appropriate workflow panel
- For ‘Run Shell Script’, search for ‘Cross enter’ and choose “as arguments”
- Now enter the next code snippet precisely*:
for FILE in "$@"
do
/choose/homebrew/bin/cwebp -q 85 "$FILE" -o "${FILE%.*}.webp"
performed
Your Fast Motion workflow ought to now seem like this:
-
- Save your Fast Motion from File > Save, identify it one thing like “Convert to WebP” (no matter you identify the Fast Motion is what’s going to seem within the Finder contextual menu)
- Go to the Finder on the Mac, and find any picture file or assortment of picture recordsdata, right-click, and choose “Convert to WebP”
The transformed webp recordsdata will seem in the identical listing with the identical file names besides carrying the webp extension.
Along with your newly created Convert to WebP Fast Motion workflow, you possibly can convert a single picture file to WebP, or if you choose a number of picture recordsdata you possibly can batch convert all of them to WebP recordsdata.
* Some notes about this little script that you could be wish to change on your explicit wants:
- The trail to cwebp is ready for cwebp put in by means of Homebrew, if you happen to put in cwebp manually then it’s in all probability in /usr/bin as an alternative and also you’d wish to modify the trail accordingly
- The -q high quality flag is at present set to 85 however you possibly can set it to something between 1-100 (larger will produce larger high quality photographs, however much less compression)
Once more, you need to use this for a single webp file conversion, or a batch conversion of many picture recordsdata, to webp format.
With how in style webp is turning into, and on condition that MacOS at present presents native capabilities to transform WebP to JPG and open WebP picture recordsdata and save the as JPEG by means of Preview (and batch changing webp to jpeg by means of that!), it appears affordable to count on {that a} future model of MacOS will assist the wrong way as properly; saving to WebP, and direct conversion to WebP. If and when that does happen, this explicit Fast Motion will not be wanted, nor will the handbook set up of cwebp from HomeBrew, however in the meanwhile that is vital.
For the unfamiliar, WebP is a picture file format created by Google that’s supposed to be environment friendly and broadly succesful, supporting nonetheless photographs and animations, and each lossy and lossless. The cwebp instrument we use right here for our functions of batch changing photographs to webp is the official WebP encoder from Google, which you’ll be able to learn extra about right here if . The shell script we use to carry out the backend conversion and compression is a modified model of what was created by Jay Holtslander from right here. And eventually, Homebrew is a very fashionable command line bundle supervisor for Mac that simply permits Mac customers to put in 1000’s of command line instruments and utilities, together with cwebp which we use right here, with out having to compile them your self.
In case you have one other most popular methodology of batch changing picture recordsdata to webp on the Mac, or an alternate method, then share it with us within the feedback beneath!