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
@KariTrace
Copy link

[11:42] aheadley haven't tested, but should work more or less
[11:43] * achin tests
[11:46] achin needs an -and -name "*.png"
[11:46] aheadley -and is implied so just -name i think
[11:47] aheadley -type f may be faster and just as effective though
[11:47] aheadley not sure
[11:47] achin markers.js isn't a png file, so it should be excluded
[11:47] aheadley markers.js shouldn't be in your tile dir?
[11:47] achin oh,
[11:47] achin i didn't give it a tiledir, just the output_dir
[11:49] aheadley oh hmmm

@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