I have these 2 input images shown below. img1.png has a car in black and the rest transparent.
img1.png
background.png
I and like to fill img1.png with the background.png image to get this output, with a white contour around the car
(it could be different shapes) and the rest transparent, to get something like this:
Note: I'm showing the car with red contour just for example purposes to see better.
Desired output
Currently I'm doing this:
Invert the alpha channel to make the car to transparent.
convert img1.png -channel a -negate +channel -fill black -colorize 100% temp.pngOverlay the car over the background.
convert -composite -gravity center background.png temp.png temp1.pngConvert black to transparent
convert temp1.png -transparent black img1_out.png
The issue is if the background image has some part of black, then inside the car the black part would be transparent too.
I think that maybe adding a white contour to the car shape previous to step 2 would help in some way to isolate the black part that I want to convert to transparent but I don't know how to add that contour after invert the alpha channel and how to convert to transparent only the black part outside the car shape. I'm using IM 7 under Cygwin for Windows.
This is my current output img1_out.png
How can I do this? Thanks





