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 »

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: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
snibgo
Posts: 12159
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 »

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 »

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