Skip to content

Instantly share code, notes, and snippets.

@dropletmedia
Created January 6, 2020 17:02
Show Gist options
  • Select an option

  • Save dropletmedia/bf391ca99955f4d70145d8457ad2d027 to your computer and use it in GitHub Desktop.

Select an option

Save dropletmedia/bf391ca99955f4d70145d8457ad2d027 to your computer and use it in GitHub Desktop.
Batch image resize and optimise
#!/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 {} +
@dropletmedia
Copy link
Author

Mark this file as executable, and add it's folder to PATH to enjoy the full benefit

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