This repository has been archived on 2024-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
fediversity_website/static/afbeeldingen/personen/resize-optimize.sh

30 lines
860 B
Bash
Raw Normal View History

2023-06-07 13:40:41 +02:00
#!/bin/sh
set -eu
if [ $# -eq 0 ]; then echo "Geef bestandsnaam op zonder extensie. michael-boelen.jpg --> michael-boelen"; exit 1; fi
if [ -f "$1.png" ]; then
# 150
convert "$1.png" -resize 150x150 "$1-150x150.png"
cwebp -q 80 "$1-150x150.png" -o "$1-150x150.webp"
optipng -o7 "$1-150x150.png"
# 200
convert "$1.png" -resize 200x200 "$1-200x200.png"
cwebp -q 80 "$1-200x200.png" -o "$1-200x200.webp"
optipng -o7 "$1-200x200.png"
elif [ -f "$1.jpg" ]; then
# 150
convert "$1.jpg" -resize 150x150 "$1-150x150.jpg"
jpegoptim -m100 "$1-150x150.jpg"
cwebp -q 80 "$1-150x150.jpg" -o "$1-150x150.webp"
# 200
convert "$1.jpg" -resize 200x200 "$1-200x200.jpg"
cwebp -q 80 "$1-200x200.jpg" -o "$1-200x200.webp"
jpegoptim -m100 "$1-200x200.jpg"
else
echo "Bestand niet gevonden"
exit 1
fi
# EOF