Skip to content

Instantly share code, notes, and snippets.

@aheadley
Created December 12, 2011 16:42
Show Gist options
  • Save aheadley/1468136 to your computer and use it in GitHub Desktop.
Save aheadley/1468136 to your computer and use it in GitHub Desktop.
#!/bin/bash
# The minimum age (in days) of tiles to modify
MIN_AGE=7
# Number of simultaneous image modifications to run, default is the number of cores
MAX_PROCS="$(grep ^processor /proc/cpuinfo | wc -l)"
# Percent of saturation to apply to new image, should be an integer from 0-100
DESATURATION=90
if [ -z "$1" ]; then
cat <<EOF
Usage: $0 path/to/tiles/ path/to/lighting/ <etc..>
EOF
elif [[ "$1" == "--helper-mode" ]]; then
IMAGEFILE="$2"
MTIME="$(stat -c %y "${IMAGEFILE}")"
mogrify -modulate "100,${DESATURATION}" "${IMAGEFILE}"
touch -d "${MTIME}" "${IMAGEFILE}"
else
find "$@" -mtime "+${MIN_AGE}" -type f -print0 | \
xargs -r -0 -n 1 -P "${MAX_PROCS}" -- "$0" --helper-mode
fi
@aheadley
Copy link
Author

updated with -type f

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