Created
June 12, 2020 10:49
-
-
Save fmnxl/da848cc575ae7306407d9dfe912426f9 to your computer and use it in GitHub Desktop.
Generate duotone image using ImageMagick
This file contains 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
#!/bin/sh | |
# A value between 0-1.0 | |
strength=0.6 | |
white="#e8a2c9" | |
black="#813722" | |
# https://unix.stackexchange.com/questions/40786/how-to-do-integer-float-calculations-in-bash-or-other-languages-frameworks/40897#40897 | |
calc() { awk "BEGIN{print $*}"; } | |
strength_inv=$(calc 1-$strength) | |
magick input.jpg \ | |
-fx "$strength * (luminance * #e8a2c9 + (1-luminance) * #813722) + $strength_inv * u" \ | |
result.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment