Mono-repo root for all personal projects
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
987 B

# Determine extension and destination for each file
# name="${file%.*}";
# Start processing
printf "Input | %s\n" "$(du -h "$file")"
# # Compress the file with Tinify API
# # Deprecated in favor of local tools, but useful every now and then for comparisons
# tinify=$(curl --progress-bar --user api:"${TINIFY_API_KEY}" --data-binary @"$file"
# tinifyUrl=$(jq '.output.url' <(echo "$tinify") | tr -d '"')
# curl --progress-bar --user api:"${TINIFY_API_KEY}" --output "$file" "$tinifyUrl"
# CWEBP optimizations
cwebp -q 90 -quiet "$file" -o "$file.webp"
# PNG and JPG specific optimizations
if [ "$extension" = "png" ]; then
pngquant --force --strip --output "$file" "$file"
optipng -force -quiet -strip all "$file"
jpegoptim --force --quiet --max=90 --strip-all "$file"
# Output results
printf "%s | %s\n" "$extension" "$(du -h "$file")"
printf "webp | %s\n\n" "$(du -h "$file.webp")"