Table of Content
Sample Script
Optimizing images is easy with this script! Img-optimizer
+ ImageMagicK
leverages multiple CLI tools to give the best results.
#!/bin/bash
# Dependencies
# - img-optimize - https://virtubox.github.io/img-optimize/
# - imagemagick
# - jpegoptim
# - optipng
for file in *.png; do convert "$file" -verbose -resize 600\> "$file"; done
img-optimize --std --path "$(pwd)"
Dependencies
imagemagick
opting
jpegoptim
Debian Command
sudo apt install jpegoptim optipng imagemagick webp -y
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
sudo ln -s $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
sudo chmod +x /usr/local/bin/img-optimize
Arch Command
yay -S jpegoptim opting imagemagick webp -y
git clone https://github.com/VirtuBox/img-optimize.git $HOME/.img-optimize
sudo ln -s $HOME/.img-optimize/optimize.sh /usr/local/bin/img-optimize
sudo chmod +x /usr/local/bin/img-optimize
Custom Script
#!/bin/bash
# Dependancies
# - img-optimize - https://virtubox.github.io/img-optimize/
# - imagemagick
# - jpegoptim
# - optipng
FOLDER="/home/ezra/ecs/website/content/images"
# max width
WIDTH=800
# max height
HEIGHT=600
#resize png or jpg to either height or width, keeps proportions using imagemagick
find ${FOLDER} -iname '*.jpg' -o -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
img-optimize --std --path ${FOLDER}