I am trying to make all green areas of a PNG file transparent. That would include any pixels where the green is mixed with another color for anti-aliasing purposes. Here's what I initially tried:
Code: Select all
convert.exe "D:\junk\01_original.png" -colorspace RGB -separate -negate "D:\junk\02_mask.png"
convert.exe "D:\junk\01_original.png" -alpha Off "D:\junk\02_mask-1.png" -compose CopyOpacity -composite PNG32:"D:\junk\03_alpha.png"
I have a workaround, which assumes that the final image is grayscale, but I would like to come up with a solution that will work with color images as well. Here's my workaround:
Code: Select all
convert.exe "D:\junk\01_original.png" -colorspace RGB -separate -negate "D:\junk\02_mask.png"
convert.exe "D:\junk\01_original.png" -alpha Off "D:\junk\02_mask-1.png" -compose CopyOpacity -composite PNG32:"D:\junk\03_alpha.png"
convert.exe "D:\junk\03_alpha.png" -colorspace Gray "D:\junk\04_alpha_grayscale.png"
convert.exe "D:\junk\04_alpha_grayscale.png" -colorspace RGB "D:\junk\05_final.png"