Skip to content

Instantly share code, notes, and snippets.

@matthiassturm
Created October 25, 2017 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiassturm/30651d7c1be2b2e260c89c7071bc284c to your computer and use it in GitHub Desktop.
Save matthiassturm/30651d7c1be2b2e260c89c7071bc284c to your computer and use it in GitHub Desktop.
Resize to square and compress
#!/bin/bash
# before running this script, do:
# brew install imagemagick jpegoptim
mkdir output
for f in *.jpg; do
convert -resize '300x300^' -gravity center -crop 300x300+0+0 ./"$f" ./output/"$f"
done
# optional: compress all images
jpegoptim -s ./output/*
du -sh ./output/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment