Last active
May 21, 2021 15:33
-
-
Save tttimur/965ac5ff153c5f7b32edcfbfb7d443ce to your computer and use it in GitHub Desktop.
Image optimization with mozjpeg and webp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is not a bash file to execute, but run the following commands in your terminal | |
# requirements (install instructions at bottom of page) | |
# imagemin-cli, imagemin-mozjpeg, imagemin-pngquant, imagemin-webp, imagemagick (mogrify) | |
-------------------------------------------------------------- | |
# 1. create the appropriate directories | |
$ mkdir build large large-webp small small-webp | |
# 2. mozjpeg compression of fullsize images | |
$ imagemin *.jpg --out-dir=build --plugin=mozjpeg && imagemin *.png --out-dir=build --plugin=pngquant | |
# 3. scale down to 50% in large dir and convert to webp | |
$ mogrify -path large -resize 50% build/* | |
$ imagemin ./large/* --out-dir=large-webp --plugin=webp | |
# 4. scale down to 30% in small dir and convert to webp | |
$ mogrify -path small -resize 30% build/* | |
$ imagemin ./small/* --out-dir=small-webp --plugin=webp | |
-------------------------------------------------------------- | |
# install instructions | |
$ npm install -g imagemin-cli imagemin-mozjpeg imagemin-webp imagemin-pngquant | |
$ brew install imagemagick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment