Skip to content

Instantly share code, notes, and snippets.

@ayosec
Created April 12, 2020 16:39
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 ayosec/c0c70e1fa33aa7b998e4f721ee457b98 to your computer and use it in GitHub Desktop.
Save ayosec/c0c70e1fa33aa7b998e4f721ee457b98 to your computer and use it in GitHub Desktop.
Directory thumbnails. Avoid memory limits in ImageMagick using subprocesses.
#!/bin/bash
set -eu -o pipefail
CMD="$(mktemp)"
for DIR in "$@"
do
echo "set -xe; montage \\" > "$CMD"
find "$DIR" -type f -name '*g' \
| while read FILE
do
echo "png:<( convert -resize 150x150 '$FILE' png:- ) \\" >> "$CMD"
done
echo "$DIR".jpeg >> "$CMD"
bash "$CMD"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment