Created
January 6, 2020 17:02
-
-
Save dropletmedia/bf391ca99955f4d70145d8457ad2d027 to your computer and use it in GitHub Desktop.
Batch image resize and optimise
This file contains hidden or 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
| #!/bin/bash | |
| # Purpose: batch image resizer | |
| # Author: Phil Picton | |
| # absolute path to image folder | |
| FOLDER="/home/phil/Desktop/pics/" | |
| # max width | |
| WIDTH=1200 | |
| # max height | |
| HEIGHT=1200 | |
| #resize jpg or png | |
| find ${FOLDER} -type f \( -iname \*.jpg -o -iname \*.png \) -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \; | |
| #lossless compress jpg | |
| find ${FOLDER} -type f -iname '*.jpg' -exec jpegoptim --strip-all {} + |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mark this file as executable, and add it's folder to PATH to enjoy the full benefit