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

Magick.NET is an object-oriented C# interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick.NET
Post Reply
martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

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

Post by martin0 » 2017-05-30T14:36:19-07:00

Hi,
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 
                image.Write("output.jpg");
            }
           

Advice gratefully received.

Martin

User avatar
fmw42
Posts: 22084
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

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

Post by fmw42 » 2017-05-30T15:31:48-07:00

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

snibgo
Posts: 9382
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo » 2017-05-30T19:46:01-07:00

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.
snibgo's IM pages: im.snibgo.com

martin0
Posts: 10
Joined: 2016-11-03T03:40:30-07:00
Authentication code: 1151

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

Post by martin0 » 2017-05-31T12:01:25-07:00

Can't imagine why I didn't see that before! doh
Thanks
Martin

Post Reply