This project has moved and is read-only. For the latest updates, please go here.

Converting(any?) image to black and white

Mar 4, 2014 at 10:05 PM
Edited Mar 4, 2014 at 10:10 PM
First off, very cool library, thank you for creating it. Also, my questions are probably more related to my lack of image understanding than the library but anyway.

I have a JPG file(which I hope uploading to photobucket did not change.

and I am trying to convert it to a pure B&W 1 bit image, using either dithering, thresholding, etc.

When I convert it to a TIFF and use GROUP 4 compression I do seem to be able to get the image to turn B&W and I've been able to successfully convert it to TIFF, open and view it in other application etc.

But I cannot seem to save it as a JPG(original format) that is 1bit B&W.

I've tried all sorts of crazy combinations of the following mutators/function calls:
.BitDepth(Channels.All, 1)
.Depth = 1

I've also tried a .Strip() before those calls based on some other responses I saw about certain profiles overriding things(not sure if I fully understand that part).

The only thing that seems to work is this:
                    this.imageData[page].QuantizeColorSpace = ColorSpace.GRAY;
                    this.imageData[page].QuantizeDither = true;
But it turns it gray, not B&W

I hope this doesn't come across at nit-picky, just curious on how to achieve what I am looking for if it is even possible.

Side question: is there any documentation on what the actual function calls do? Like an MSDN/API doc?

Mar 5, 2014 at 6:21 AM
Edited Mar 8, 2014 at 8:43 PM
The .Strip method does not influence the value of a pixel. It removes metadata from an image file (

You should be able to do the following (this is the equivalent of convert.exe photo_zps3b2313f9.jpg -threshold 25% blackwhite.jpg):
using (MagickImage image = new MagickImage(@"photo_zps3b2313f9.jpg"))
But this does not seem to work and creates a completely white image. I will have to investigate this for you to figure out what is happening.

If you are looking for documentation about what actual function calls do I would advise you to visit: or check the command line options on this page: The names of the command line options are almost the same as the methods in the MagickImage class.
Mar 5, 2014 at 5:10 PM
Thank you very much for the response. I appreciate the link as well. I somehow missed that in all of my searching.

Mar 8, 2014 at 8:45 PM
That link can be found on the bottom of the documentation page. I have made this more clear so it won't be that easy to miss it anymore.

The problem with Threshold will be fixed in the next release of Magick.NET. It will use a percentage instead. You can find an example in this topic: