title: ImageMagick (Magick.NET) 's Pdf to Jpg/Tiff operation gives me wrong color for CMYK to CMYK
body: <p><strong>Issue</strong></p>
  <p>When converting to Jpg/Tiff (CMYK), output images has different CMYK values for same areas from the input:</p>
  <ul>
  <li>(100)C become (76)C, (7)M, (14)Y</li>
  <li>(100)M become (87)M, (5)Y</li>
  <li>(100)Y become (85)Y</li>
  <li>(100)K become (72)C, (67)M, (67)Y, (88)K</li>
  <li>Pure white stays (0)C, (0)M, (0)Y, (0)K</li>
  </ul>
  <p><strong>History</strong></p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/63044125/need-to-rasterize-pdf-into-cmyk-image-for-printing-but-all-libraries-give-me-cm/63050028#63050028">My last wrong question</a></li>
  <li><a href="https://stackoverflow.com/questions/8801633/php-imagick-cmyk-pdf-convert-to-jpg">A not necessarily related question about IM</a> and <a href="https://stackoverflow.com/questions/21270389/imagemagick-promote-grays-to-cmyk-black">a second one</a>.</li>
  </ul>
  <p><strong>Sample code</strong></p>
  <pre><code>using System;
  using System.Collections.Generic;
  using ImageMagick;
  
  namespace stackOVERFLOW
  {
      class Sample
      {
          public static void Start()
          {
              Rasterize(&quot;SOSample.pdf&quot;);
          }
          static void Rasterize(string input)
          {
              var settings = new MagickReadSettings
              {
                  Density = new Density(300, 300),
                  ColorSpace = ColorSpace.CMYK
              };
              var images = new MagickImageCollection();
              images.Read(input, settings);
              images[0].Format = MagickFormat.Jpg; //or .Tiff
              images[0].Write(input[0..^4] + &quot;.jpg&quot;); // or &quot;.tiff&quot;
          }
      }
  }
  </code></pre>
  <p><strong>Input</strong></p>
  <ul>
  <li><a href="https://github.com/dlemstra/Magick.NET/files/4965415/SOSample.pdf" rel="nofollow noreferrer">Input PDF</a> (CMYK with pure C, M, Y, K and white areas)</li>
  </ul>
  <p><strong>Output</strong></p>
  <ul>
  <li><a href="https://i.stack.imgur.com/zKvK2.jpg" rel="nofollow noreferrer">JPG</a> (Separation: <a href="https://i.stack.imgur.com/2bfLx.jpg" rel="nofollow noreferrer">C</a> | <a href="https://i.stack.imgur.com/3zijW.jpg" rel="nofollow noreferrer">M</a> | <a href="https://i.stack.imgur.com/z7cQ7.jpg" rel="nofollow noreferrer">Y</a> | <a href="https://i.stack.imgur.com/dProW.jpg" rel="nofollow noreferrer">K</a> )</li>
  </ul>
  <p><strong>Code for channel separation</strong> (used for output sample)</p>
  <pre><code>List&lt;String&gt; colors = new List&lt;String&gt; { &quot;C&quot;, &quot;M&quot;, &quot;Y&quot;, &quot;K&quot; };
  int n = 0;
  foreach (IMagickImage&lt;ushort&gt; channel in images[0].Separate(Channels.All))
  {
      channel.Negate();
      channel.Write(input[0..^4] + &quot;_&quot; + colors[n] + &quot;.jpg&quot;);
      n++;
  }
  </code></pre>
  <p><strong>Interpretation of the problem</strong></p>
  <p>When converting to PNG (RGB) colors looks right for RGB, the feeling is that it's been converted to RGB before CMYK.</p>
  <pre><code>images[0].Format = MagickFormat.Png;
  images[0].Write(input[0..^4] + &quot;.png&quot;);
  </code></pre>
  <p><strong>Purpose</strong></p>
  <p>It's for offset plate setting purpose, it's important the black to stay pure black (and the CMYK values in general) for many reasons including color quality, 1 color printing (B&amp;W), etc.</p>
  <p><strong>Finally</strong></p>
  <ul>
  <li>Is there any way to get the expected result with Magick.net?</li>
  <li>Is there any way to get the expected result with Ghostscript itself?</li>
  <li>If you know any way to get CMYK raster image from a PDF, help me, I'm open for any language, etc.</li>
  </ul>
  <p><strong>Aditional Information:</strong></p>
  <p>Using Magick.NET-Q16-x64 v7.21.0 NuGet package</p>