Last active
February 27, 2024 18:59
-
-
Save PauloLuan/5f32d8509e4b0b84074b6e168eeffd00 to your computer and use it in GitHub Desktop.
png_to_webp.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Loop through all PNG files in the current directory | |
for png_file in *.png; do | |
if [ -f "$png_file" ]; then | |
# Get the filename without the extension | |
filename=$(basename -- "$png_file") | |
filename_noext="${filename%.*}" | |
# Convert the PNG to WebP | |
cwebp "$png_file" -o "${filename_noext}.webp" -quiet | |
echo "Converted $png_file to ${filename_noext}.webp" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment