I am converting a PDF to a Tiff File using GhostScript and ImageMagick in a C# winform app, but I am not getting the correct settings in the result.
DPI is set to 300 with GhostScript, and 8-Bit Depth with ImageMagick. The file is returning as 40-Bit with 96 DPI.
// GhostScript PDF to TIFF Conversion
private void GS_ConvertPdfToTiff(string pdfPath, string outputFolder) {
using (var rasterizer = new GhostscriptRasterizer()) {
rasterizer.Open(pdfPath);
for (int pageNumber = 1; pageNumber <= rasterizer.PageCount; pageNumber++) {
string outputPath = Path.Combine(outputFolder, $"GhostMagick_{pageNumber}.tif");
using (Bitmap img = new Bitmap(rasterizer.GetPage(300, pageNumber))) // 300 DPI
{
ImgMgkConvertToCMYK(img, outputPath);
}
}
}
}
// Convert Bitmap to CMYK and save with ImageMagick
private void ImgMgkConvertToCMYK(Bitmap image, string outputPath) {
using (var memoryStream = new MemoryStream()) {
// Save the Bitmap to MemoryStream
image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);
memoryStream.Seek(0, SeekOrigin.Begin); // Reset stream position
// Load the image from the memory stream into MagickImage
using (var magickImage = new MagickImage(memoryStream)) {
// Set to CMYK color space
magickImage.ColorSpace = ColorSpace.CMYK;
magickImage.Depth = 8; // 8-bit depth for printing
magickImage.Write(outputPath); // Save to the provided path (Map.tif)
}
}
}
Conversion Requirements: 300 dpi CMYK (color encoding) Bit Depth - 8 bit Anti-Aliased
Any insights on to why this might be happening and how to get the correct conversion?
Thanks.




image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png);- why Png?