Page 1 of 1

IM masking question on black transforms

Posted: 2017-01-23T05:55:42-07:00
by jonnabu4
Hello,

I am an imagemagick rookie, and I am trying to apply a mask on a black n white photo, so in the end, I have black of the photo turned to transparent.

I am transforming #000000 to #010101 for the original image to begin with, but when, after applying the mask I am turning all true black to transparent, I need to use a fuzz factor of 3%. And that again creates transparency in my photo obviously.

Is there something else I can do other than setting fuzz to 0% or turning the original true black to an even lighter gray?

Here is my script now:

convert ${previousline} -fill '#010101' -opaque '#000000' -scale 620x380+0+0 ${targetfile}
convert ${template-pic-mask_local} ${previousline} -geometry +48+52 ${template-pic-mask_local} -compose multiply -composite ${targetfile}
convert ${previousline} -fuzz 3% -transparent '#000000' ${targetfile}
convert ${template-pic-main_local} ${previousline} -geometry +241+25 -composite ${targetfile}

Any help will be very much appreciated! Thank you in advance :)

Re: IM masking question on black transforms

Posted: 2017-01-23T06:08:52-07:00
by snibgo
You have four convert commands. They all create or re-create ${targetfile}. So the first three have zero effect.

I don't understand what you want to do. Perhaps you want to make all black pixels transparent, and leave all the others untouched. If so, then:

Code: Select all

convert in.png -transparent Black out.png

Re: IM masking question on black transforms

Posted: 2017-01-23T10:16:51-07:00
by jonnabu4
I forgot to mention that {$previousline} always dynamically get the result of each previous command's {$targetfile}.
So I can see that the first four commands are working.
The biggest issue is that fuzz takes along non-true black pixels, pixels of the original photo. While the mask needs the fuzz factor to be applied smoothly. :)

I hope this helps into understanding the issue. :)

Re: IM masking question on black transforms

Posted: 2017-01-23T11:00:27-07:00
by snibgo
So each ${previousline} is the previous command's ${targetfile}? That makes debugging "interesting". Why not use just one command? Any other weird rules we need to know about?

Sorry, I still don't know what you are trying to do. If you supplied your input files, that might help.