Probably all of us have been in a situation where we had to convert more than a few images to one format or the other for whatever reason. Converting them manually with a GUI program can quickly become tedious and once again I found myself in such a situation. So I decided to look for a CLI solution and finally found one: a tool named cwebp, which is part of the package libwebp (that's the package name in Arch repo but it could differ for your distro). Libwebp is a mandatory dependency for ffmpeg, ffmpeg4.4, gimp, qt5-imageformats, qt6-imageformats, qt6-webengine, thunderbird and many others, so if you have any of these packages installed, then it's highly likely that you also have libwebp installed. Despite its name, "cwebp" (stands for "convert webp") can convert to and from webp, as well as PNG-JPG two-way.
I wrote a few scripts (by "trial and error", until I discovered exactly how the tool works and a little help from an AI) for the most frequently used formats on the internet, including on YouTube when you upload a video (YT requres JPG image no larger than 1 MB). This tool is doing the job perfectly, so I decided to share these scripts in case you too need them:
Bulk JPG to PNG:
Bulk PNG to JPG:
Bulk PNG to WEBP:
Ofc there can be other combinations but since I need to use these most frequently, I wrote scripts only for them. You can rewrite them for whatever format range you want, just keep in mind that animated images (GIF) are not supported.
I wrote a few scripts (by "trial and error", until I discovered exactly how the tool works and a little help from an AI) for the most frequently used formats on the internet, including on YouTube when you upload a video (YT requres JPG image no larger than 1 MB). This tool is doing the job perfectly, so I decided to share these scripts in case you too need them:
Bulk JPG to PNG:
Code:
#!/bin/bash
for file in *.jpg;
do cwebp -q 100 "$file" -o "${file/.jpg/}.png";
done
Bulk PNG to JPG:
Code:
#!/bin/bash
for file in *.png;
do cwebp -q 100 "$file" -o "${file/.png/}.jpg";
done
Bulk PNG to WEBP:
Code:
#!/bin/bash
for file in *.png;
do cwebp -q 100 "$file" -o "${file/.png/}.webp";
done
Ofc there can be other combinations but since I need to use these most frequently, I wrote scripts only for them. You can rewrite them for whatever format range you want, just keep in mind that animated images (GIF) are not supported.