Reputation: 33
Issue
When converting to Jpg/Tiff (CMYK), output images has different CMYK values for same areas from the input:
History
Sample code
using System;
using System.Collections.Generic;
using ImageMagick;
namespace stackOVERFLOW
{
class Sample
{
public static void Start()
{
Rasterize("SOSample.pdf");
}
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] + ".jpg"); // or ".tiff"
}
}
}
Input
Output
Code for channel separation (used for output sample)
List<String> colors = new List<String> { "C", "M", "Y", "K" };
int n = 0;
foreach (IMagickImage<ushort> channel in images[0].Separate(Channels.All))
{
channel.Negate();
channel.Write(input[0..^4] + "_" + colors[n] + ".jpg");
n++;
}
Interpretation of the problem
When converting to PNG (RGB) colors looks right for RGB, the feeling is that it's been converted to RGB before CMYK.
images[0].Format = MagickFormat.Png;
images[0].Write(input[0..^4] + ".png");
Purpose
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&W), etc.
Finally
Aditional Information:
Using Magick.NET-Q16-x64 v7.21.0 NuGet package
Upvotes: 1
Views: 2418
Reputation: 33
dlemstra (Magick.net) answered me in GitHub this output is because PDF decoder of ImageMagick used the option -dUseCIEColor
, they will fix it in the next release. For more information check the GitHub Discussion.
Upvotes: 1
Reputation: 31199
Well, Ghostscript produces the correct output, so I'd have to guess ImageMagick is doing something to it. Or possibly using the wrong device. Obviously I don't know what IM does to get Ghostscript to turn a PDF file into 'something else'.
This:
gs -sDEVICE=jpegcmyk -o out.jpg cmyk.pdf
produces a JPEG file where each of the rectangles is a pure shade of C, M, Y or K. Checked using the eyedropper tool in Adobe Photoshop.
Upvotes: 1