jcompton wrote:This is working well for the original purpose, but it turns out that it would also be useful to be able to map any (0,0,0,x) (any black, regardless of transparency level, including 0.0 and 1.0) to be (0,0,0,0.5) . Any ideas how I can make that happen? Maybe I'm misunderstanding things but the -opaque and -transparent operators seem to be getting in my way and I can't even work out how to do it in two passes.
This is at least one way to do it, but it is slow:
create test gradient with gradient alpha channel:
convert -size 256x256 gradient: -alpha copy tmp.png
change any pixel with graylevel r=g=b=20 (range 0-255) irrespective of alpha value to r=g=b 200 with mid value (127) alpha.
NOTE this appears to be an inconsistency in how alpha is specified in -fx as rgba values should be specified with alpha in range 0 to 1 whether rgb are in range 0-255 or 0-100%. I tried alpha of 0, 1 and 0.5 and it objected when I used 0.5
convert tmp.png -alpha on -channel rgba -fx 'u.r==20/255&&u.g==20/255&&u.b==20/255?rgba(200,200,200,127):u' tmp1.png
Perhaps Anthony has a better way and can explain this potential inconsistency.