convert to monochrome

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
Posts: 1
Joined: 2016-03-21T03:10:21-07:00
Authentication code: 1151

convert to monochrome

Post by bman » 2016-03-21T03:14:45-07:00


I'm converting a pdf to images and wanto convert these to black/white.

It is working to get a grayscale output but I cannot find how to get 1 bit images.

Code used

Code: Select all

  MagickReadSettings settings = new MagickReadSettings();
            // Settings the density to 300 dpi will create an image with a better quality
            PointD xx = new PointD(300, 300);
            settings.Density =  xx;
            using (MagickImageCollection images = new MagickImageCollection())
                // Add all the pages of the pdf file to the collection
                images.Read(@"D:\Projects\imagemagick\pdfs\outofmem.pdf", settings);

                int page = 1;
                foreach (MagickImage image in images)
                    // Write page to file that contains the page number
                    image.ColorSpace = ColorSpace.Gray;
                    image.Write(@"D:\Projects\imagemagick\pdfs\" + "outofmem.Page" + page + ".jpg");


User avatar
Posts: 1561
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789

Re: convert to monochrome

Post by dlemstra » 2016-03-24T14:40:03-07:00

You can get an all black and white image (1-bit) when you set the ColorType of the image to ColorType.BiLevel. You do need to save the file in someting like png/tiff to actually store it in 1 bit.
.NET + ImageMagick = Magick.NET, @MagickNET, Donate

Post Reply