Skip to content

Instantly share code, notes, and snippets.

@koveseb
Created February 6, 2021 18:50
Show Gist options
  • Save koveseb/0acef315aa34631f53ab183521206e88 to your computer and use it in GitHub Desktop.
Save koveseb/0acef315aa34631f53ab183521206e88 to your computer and use it in GitHub Desktop.
Resizes batches of images
#!/usr/bin/env bash
# Purpose: batch image resizer
# Source: https://guides.wp-bullet.com
# Author: Mike
# absolute path to image folder
FOLDER="images"
# max height
HEIGHT=800
# max width
WIDTH=800
#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\> \{} \;
#resize png to either height or width, keeps proportions using imagemagick
#find ${FOLDER} -iname '*.png' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
#resize jpg only to either height or width, keeps proportions using imagemagick
find ${FOLDER} -iname '*.jpg' -exec convert \{} -verbose -resize $WIDTHx$HEIGHT\> \{} \;
# alternative
#mogrify -path ${FOLDER} -resize ${WIDTH}x${HEIGHT}% *.png -verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment