imagemagickimagemagick-convert

Change opacity of lighten composition layer


I'm using the command below to overlay an image (../esrgan/{1}) with another image ({1}) that I scale to 400% and then apply lighten composition to.

parallel --bar --xapply convert {1} -filter Lanczos -resize 400% ../esrgan/{1} +swap -compose Lighten -composite ../esrgan/{1} ::: *.png

On top of that, I also want to set the opacity of the top layer ({1}) to 75%. How do I do that?


Solution

  • I'm not familiar with your complete syntax there, but within the part that is appears to be an ImageMagick command, right after the "-resize" and before reading in the second image, add this to the code...

    ... -channel A -evaluate set 75% +channel ...
    

    That tells the command to only use the alpha channel for the following operation(s). The "-evaluate" operation sets the alpha channel to a value of 75%. Then the "+channel" with the plus "+" ends that special setting and continues with the command.

    If the first input file doesn't have an alpha channel, you can add "-alpha set" to make sure the image has an alpha channel before changing the value.