Created
November 4, 2024 18:00
-
-
Save bgrins/8a043cb72f7f15394f57702cdcb81af5 to your computer and use it in GitHub Desktop.
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 | |
# install vips at https://www.libvips.org/install.html | |
input_dir="assets/images/" | |
quality=50 | |
for input_file in "$input_dir"/*.{jpg,jpeg,png}; do | |
echo "Processing $input_file" | |
if [[ ! -f "$input_file" ]]; then | |
continue | |
fi | |
output_file="${input_file}.avif" | |
if [[ -f "$output_file" ]]; then | |
echo "Skipping $input_file (already converted)" | |
continue | |
fi | |
vips copy "$input_file" "$output_file[Q=$quality]" | |
echo "Converted $input_file to $output_file with quality $quality" | |
done | |
echo "All files in $input_dir have been converted." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment