Page 1 of 1

convert -level 25%,75% in Magick.Net

Posted: 2017-05-30T14:36:19-07:00
by martin0
I'm trying to achieve the equivalent of convert.exe input.jpg -level 25%,75% output.jpg

I'm using MagickImage ContastStretch method. Basically it's not working.

Code: Select all

           using (MagickImage image = new MagickImage("input.jpg"))
                image.ContrastStretch(new Percentage(25), new Percentage(75));
                // Save image 

Advice gratefully received.


Re: convert -level 25%,75% in Magick.Net

Posted: 2017-05-30T15:31:48-07:00
by fmw42
contrast-stretch 25%,75% is not the same as using -level 25%,75% in percent. Contrast-stretch clips by percentage of pixels. Level adjusts by percent graylevel. So you are using the wrong function in Magick.NET

Re: convert -level 25%,75% in Magick.Net

Posted: 2017-05-30T19:46:01-07:00
by snibgo
You posted this in the Magick.NET forum, but it looks more like Magick++ to me. I don't use either.

Anyhow, as Fred says the constrastStretch() function will correspond to the CLI command "-contrast-stretch". As you want "-level", the level() function seems more likely.

Re: convert -level 25%,75% in Magick.Net

Posted: 2017-05-31T12:01:25-07:00
by martin0
Can't imagine why I didn't see that before! doh