for i in *.webp; do name=`echo "$i" | cut -d'.' -f1`; convert "$i" "${name}.jpg"; done
When I find myself needing to convert a directory full of WebP images to JPG or PNG, Linux and ImageMagick is always there to help.
Step 1: Check if ImageMagick is Installed
First, make sure ImageMagick is installed. You can check by running:
convert --version
If it’s not already installed, no worries—it’s easy to set up on Ubuntu:
sudo apt update
sudo apt install imagemagick
Step 2: Convert WebP to JPG
Now with ImageMagick you can convert all WebP images in the current directory with this one-liner:
for i in *.webp; do name=`echo "$i" | cut -d'.' -f1`; convert "$i" "${name}.jpg"; done
Breaking down the command:
for i in *.webp;
loops through every WebP file in the directory.name=
echo “$i” | cut -d’.’ -f1;
strips the.webp
extension to leaving just the filename.convert "$i" "${name}.jpg";
converts all WebP files in the loop to JPG.
Step 3: Done!
After running the command, all your images are converted to JPG format, ready for using where you need them.