2024-01-11 20:04:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-13 16:15:24 +00:00
|
|
|
# Libary needed: ImageMagick
|
|
|
|
|
|
|
|
PARAMS=('-quality 60')
|
2024-01-11 20:04:55 +00:00
|
|
|
|
|
|
|
if [ $# -ne 0 ]; then
|
|
|
|
PARAMS=$@;
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $(pwd)
|
|
|
|
|
|
|
|
shopt -s nullglob nocaseglob extglob
|
|
|
|
shopt -s globstar
|
|
|
|
|
|
|
|
# Resize
|
2024-01-13 16:15:24 +00:00
|
|
|
sizes=(320 640 960 1280)
|
2024-01-15 21:55:39 +00:00
|
|
|
for FILE in public/**/*.@(jpg|jpeg|tif|tiff|png|gif); do
|
2024-01-13 16:15:24 +00:00
|
|
|
DIR=$(dirname "$FILE")
|
|
|
|
NAME=$(basename "$FILE" | cut -d. -f1)
|
|
|
|
EXTENSION=$(basename "$FILE" | cut -d. -f2)
|
|
|
|
for size in ${sizes[@]}; do
|
|
|
|
convert "$FILE" -resize ${size}x${size}\> "${DIR}/${NAME}-${size}.${EXTENSION}"
|
|
|
|
done
|
|
|
|
done
|
2024-01-11 20:04:55 +00:00
|
|
|
|
|
|
|
# Web Optimized Formats
|
2024-01-15 21:55:39 +00:00
|
|
|
for FILE in public/**/*.@(jpg|jpeg|tif|tiff|png|gif); do
|
2024-01-11 20:08:31 +00:00
|
|
|
convert $PARAMS "$FILE" "${FILE}".webp;
|
|
|
|
convert $PARAMS "$FILE" "${FILE}".avif;
|
2024-01-11 20:04:55 +00:00
|
|
|
done
|