Last active
April 10, 2022 10:09
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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