Attempting to open an image, set its resolution, and save it, and I'm running into an issue where the ColorSpace
is being modified without any input on my end.
The input image is a blank sRGB/8 image, checking img.ColorSpace
after creation shows sRGB
, however after setting the density, writing the image to disk, and opening the output, the ColorSpace
is set to Gray
.
using (var img = new MagickImage(inputImagePath))
{
img.Density = new Density(parameters.HorizontalResolution, parameters.VerticalResolution);
img.Write(outputImagePath);
// img.ColorSpace is sRGB
}
using (var imgCheck = new MagickImage(outputImagePath))
{
// imgCheck.ColorSpace is gray
}
The downstream code requires the colorspace on the output image to be the same as the input image's. Is there a parameter for MagickImage.Write()
that can preserve the color space?