Skip to content

Instantly share code, notes, and snippets.

@pepijndevos
Last active April 10, 2022 10:09
Show Gist options
  • Save pepijndevos/12498d680a8ec53c0b92308c6e2a6bbb to your computer and use it in GitHub Desktop.
Save pepijndevos/12498d680a8ec53c0b92308c6e2a6bbb to your computer and use it in GitHub Desktop.
Replace colors in an image with random ones and assemble into a montage
set -ex
ORIGINAL="fox.jpg"
OG_SHIRT="#224e2b"
OG_PANTS="#9f6e4e"
function rand {
echo $(($1 + ($RANDOM % ($2 - $1))));
}
mkdir -p tiles
for i in {1..60}
do
PANTS="hsb(`rand 0 360`, `rand 0 100`, `rand 50 256`)"
SHIRT="hsb(`rand 0 360`, `rand 100 200`, `rand 50 256`)"
convert $ORIGINAL \
-fuzz 10% -fill "$SHIRT" -opaque $OG_SHIRT \
-fuzz 5% -fill "$PANTS" -opaque $OG_PANTS \
tiles/$i.jpg
done
montage -geometry +0+0 -tile 20x3 tiles/* montage.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment