Skip to content

Instantly share code, notes, and snippets.

@ip413
Forked from dymio/Gradient map with ImageMagick
Created January 26, 2022 14:21
Show Gist options
  • Save ip413/84553dbe08e7aa37bf82b59e9bd86a04 to your computer and use it in GitHub Desktop.
Save ip413/84553dbe08e7aa37bf82b59e9bd86a04 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Imagemagick analogue of Adobe Photoshop Gradient map with 75% opacity on it
# you will need the input.jpg file with original color image
# and gradient_line.png file with 256 x 1 px image of gradient
# make image grayscale
convert input.jpg -colorspace gray draft.jpg
# apply the gradient lut
convert draft.jpg gradient_line.png -clut draft.jpg
# set 75% opacity
convert draft.jpg -alpha on -channel a -evaluate set 75% draft.png
# impose result image on original image
convert the_in.jpg temp.png -gravity center -composite -format jpg -quality 90 output.jpg
# remove temporary files
rm draft.jpg && rm draft.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment