Skip to content

Instantly share code, notes, and snippets.

@victoriadrake
Created February 3, 2020 21:28
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 victoriadrake/838e1f7494a9d205c2bfaf2304bed534 to your computer and use it in GitHub Desktop.
Save victoriadrake/838e1f7494a9d205c2bfaf2304bed534 to your computer and use it in GitHub Desktop.
# Look in the public/ directory
find public/ \
# Ignore directories called "static" regardless of location
-not -path "*/static/*" \
# Print the file paths of all files ending with any of these extensions
\( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) -print0 \
# Pipe the file paths to xargs and use 8 parallel workers to process 2 arguments
| xargs -0 -P8 -n2 \
# Tell mogrify to strip metadata, and...
mogrify -strip \
# ...compress and resize any images larger than the target size (1000px in either dimension)
-thumbnail '1000>' \
# Convert the files to jpg format
-format jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment