My entire collection compressed down to 36GB! and that's without changing the aspect or size. Here it is:
Install software:
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
SCRIPT run in terminal
[change ONLY the FOLDER= line and the max width height values.
Sorry, This is the original code with no values set. I was so excited I put my term output in instead of the original correct code itself.
It's primarily a compressor to save space. Max Width and Height are limits only.
Code: Select all
#!/bin/bash
# Dependancies
# - img-optimize - https://virtubox.github.io/img-optimize/
# - imagemagick
# - jpegoptim
# - optipng
FOLDER="/home/titus/github/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}