Skip to content

Instantly share code, notes, and snippets.

@jiri001meitner
Last active February 20, 2018 09:32
Show Gist options
  • Save jiri001meitner/2947b63c01b96c35e66f6a974e473037 to your computer and use it in GitHub Desktop.
Save jiri001meitner/2947b63c01b96c35e66f6a974e473037 to your computer and use it in GitHub Desktop.
optimages
#!/bin/bash
optidir="$*"
fronta="$(mktemp)"
find "${optidir}/" -type f -iname *.jpg -exec du -a {} + | sort -n -r | cut -f 2 >"$fronta"
while read line
do
printf "%s\n" "$line"
jpeg-recompress -q medium -l 128 -a -c -m smallfry "$(printf "%s\n" "$line")" "$(printf "%s\n" "$line")"
done <"$fronta"
rm "$fronta"
exit
@jiri001meitner
Copy link
Author

https://guides.wp-bullet.com/batch-optimize-jpg-lossy-linux-command-line-with-jpeg-recompress/
https://guides.wp-bullet.com/batch-optimize-jpg-lossy-linux-command-line-with-jpeg-recompress/

sudo apt-get install build-essential autoconf pkg-config nasm libtool
git clone https://github.com/mozilla/mozjpeg.git
cd mozjpeg
autoreconf -fiv
./configure --with-jpeg8
make
sudo make install

apt install nodejs optipng
npm install -g svgo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment