31 lines
No EOL
691 B
Bash
Executable file
31 lines
No EOL
691 B
Bash
Executable file
#!/bin/bash
|
|
|
|
# Libary needed: ImageMagick
|
|
|
|
PARAMS=('-quality 60')
|
|
|
|
if [ $# -ne 0 ]; then
|
|
PARAMS=$@;
|
|
fi
|
|
|
|
cd $(pwd)
|
|
|
|
shopt -s nullglob nocaseglob extglob
|
|
shopt -s globstar
|
|
|
|
# Resize
|
|
sizes=(320 640 960 1280)
|
|
for FILE in static/**/*.@(jpg|jpeg|tif|tiff|png|gif); do
|
|
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
|
|
|
|
# Web Optimized Formats
|
|
for FILE in static/**/*.@(jpg|jpeg|tif|tiff|png|gif); do
|
|
convert $PARAMS "$FILE" "${FILE}".webp;
|
|
convert $PARAMS "$FILE" "${FILE}".avif;
|
|
done |