Change .webp to .jpg
You can convert .webp
files to .jpg
using a Linux shell script by utilizing tools such as imagemagick
or libwebp
. Below is an example of a script that uses imagemagick
, which provides the convert
command:
- Install ImageMagick (if not already installed):
sudo apt-get install imagemagick
- Create the shell script:
#!/bin/bash # Directory containing .webp files DIRECTORY="path_to_your_directory" # Loop through all .webp files in the directory for FILE in "$DIRECTORY"/*.webp; do # Get the base name of the file (without extension) BASENAME=$(basename "$FILE" .webp) # Convert to .jpg convert "$FILE" "$DIRECTORY/$BASENAME.jpg" done echo "Conversion completed!"
- Make the script executable:
chmod +x convert_webp_to_jpg.sh
- Run the script:
./convert_webp_to_jpg.sh
Replace path_to_your_directory with the actual path to the directory containing your .webp files. This script will loop through each .webp file in the specified directory, convert it to a .jpg file with the same base name, and save it in the same directory.
If you prefer to use libwebp, here’s an alternative script:
- Install libwebp tools (if not already installed):
sudo apt-get install webp
- Create the shell script:
#!/bin/bash # Directory containing .webp files DIRECTORY="path_to_your_directory" # Loop through all .webp files in the directory for FILE in "$DIRECTORY"/*.webp; do # Get the base name of the file (without extension) BASENAME=$(basename "$FILE" .webp) # Convert to .jpg dwebp "$FILE" -o "$DIRECTORY/$BASENAME.jpg" done echo "Conversion completed!"
- Make the script executable:
chmod +x convert_webp_to_jpg.sh
- Run the script:
./convert_webp_to_jpg.sh
Again, replace path_to_your_directory with the actual path to your directory containing .webp files. This script will also convert each .webp file in the specified directory to a .jpg file with the same base name.