I have around 100 .png
images, and all of them have to be converted to .webp
(Google's image format). I am using Google's CLI tool. Any idea how to batch process them.
Google's proprietary image format WEBP is arguably better than the standard JPG or PNG format. It creates a much smaller file size than JPG and still supports the transparency feature of PNG without much loss in quality.
CloudConvert converts your image files online. Amongst many others, we support PNG, JPG, GIF, WEBP and HEIC. You can use the options to control image resolution, quality and file size.
Use a browser that does not support webp You can run Firefox or Internet Explorer instead for all your image downloading needs, so that the images are automatically saved as png or jpg images. If you rely on Chrome, try the User Agent Switcher extension instead which fakes the browser you are using.
Webp is a image format developed by Google for web graphics, you can rename the file using file. jpeg naming to open it normally, this happens because there are many extensions like jpeg, png, bmp, webp, Google saves image in webp format because it was originally webp image not jpeg I guess.
You can do it with a help of a simple bash
script.
Navigate to the directory where your images reside and execute this:
$ for file in * > do > cwebp -q 80 "$file" -o "${file%.png}.webp" > done
You can change the output file name, as you want. But should end with a .webp
extension.
You need to use GNU Parallel if you have that many, or you will be there all year!
Please copy a few files into a spare temporary directory first and try this there to be sure it does what you want before using it on 100,000 images:
parallel -eta cwebp {} -o {.}.webp ::: *.png
That will start, and keep running, as many processes as you have CPU cores, each doing a cwebp
. The files processed will be all the PNG
files in the current directory.
If the command line gets too long, you can pass the file list in using find
like this:
find . -name "*.png" | parallel -eta cwebp {} -o {.}.webp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With