Page 1 of 1

combining chained convert commands into one

Posted: 2015-09-09T18:41:29-07:00
by sas
I'm trying to darken and blur a grayscale PNG image, and then replace all pixels which are darker than gray2, with gray2.

This works fine:

Code: Select all

convert a.png  -level 0%,85%  -blur 0x5   b.png
convert b.png  -black-threshold '2%'      c.png
convert c.png  -fill gray2 -opaque black  d.png
However if I try to combine them all into one command to avoid creating the intermediate images b.png and c.png, it doesn't have the same result:

Code: Select all

convert a.png  -level 0%,85%  -blur 0x5 \
               -black-threshold '2%' \
               -fill gray2 -opaque black  d.png
What am I missing?

Re: combining chained convert commands into one

Posted: 2015-09-09T20:57:24-07:00
by fmw42
Your two commands should work the same. What version of IM, libpng and what platform are you using? Post an example of a.png and your two d.png results to some place such as dropbox.com and then put the URLs here.

You could add a little -fuzz XX% in case some values are not quite at gray2. But in principle, you commands should work.

Your command -level 0x85% is going to brighten the image, not darken it.

Re: combining chained convert commands into one

Posted: 2015-09-10T07:48:16-07:00
by sas
Huh, you're right, it does work.

No idea what I did wrong when I tried it yesterday... :oops:

Thanks for responding!
fmw42 wrote:You could add a little -fuzz XX% in case some values are not quite at gray2. But in principle, you commands should work.
I'm not replacing gray2 pixels, I'm replacing a range of pixel values to gray2.

(Maybe I chose a strange way to do it?)

Re: combining chained convert commands into one

Posted: 2015-09-10T09:48:30-07:00
by fmw42
try

Code: Select all

convert a.png -level 0%,85%  -blur 0x5 -evaluate max 2% d.png