zappzerapp wrote: ↑
I have a JPG image which contains a path and would like to cut along the path, fill the background with #ff6 and then multiply it with the original image to match the shadow.
Edited – Thu Feb 13 01:37:57 UTC 2020 – I posted a workable solution here several hours ago, but have since come up with a much simpler and more versatile method.
Since the clipping path designates the subject of the image, and we want to isolate and modify the background, we have to more or less reverse the effect of the path. This command will produce the result in your example image...
Code: Select all
convert 1581506712.jpg -write mpr:in \( +clone -fill "#ff6" -colorize 100 \) \
-compose multiply -composite mpr:in -clip -compose over -composite result.png
That starts by reading in the JPG image, then writes a copy of it to a memory register to save for later in the command. Then inside the parentheses it makes a clone and colorizes it entirely to "#FF6". After the parentheses it uses "-compose multiply" to composite that yellow image onto the original input.
So far so good, but multiplying that yellow tinting has also affected the car, which we don't want. So then we bring that copy "mpr:in" back into the command, and by setting the "-clip" and following with "-compose over -composite" it will composite only the inside of the clipping path, the car part of the input image, over the yellow tinted image we just created. Write the output file and it's done.
This command works for me in IM v6.8.9 in a bash shell, and by eliminating the backslashes "\" and changing that continued-line backslash "\" to a caret "^" it works in v6.9.10 at a Windows command prompt. Change "convert" to "magick" and it works in IMv7.