-1

我无法通过使用 ImageMagick 将 PDF 转换为图像来获得良好的色彩质量。

 MagickReadSettings settings = new MagickReadSettings();
        settings.Verbose = true;
        settings.Density = new Density(600, 600);

        MagickImageCollection images = new MagickImageCollection();
        images.Read("C:\\" + Path.GetFileName(fileUrl));
        List <string> files = new List<string>();
        for (var x = 0; x < images.Count; x++)
        {
            images[x].Quality = 100;
            images[x].BitDepth(24);
            images[x].Contrast(true);
            images[x].Resize(3675, 2400);
            images[x].Write("C:\\websites\\FlyerEditor2\\FlyerEditor\\src\\assets\\" + Path.GetFileNameWithoutExtension(fileUrl) + "-" + (x + 1) + ".jpeg");
            files.Add("assets/" + Path.GetFileNameWithoutExtension(fileUrl) + "-" + (x + 1) + ".jpeg");
        }

从pdf裁剪的屏幕截图

使用imageMagick从pdf转换为jpg

4

3 回答 3

1

如果使用python3,你可以尝试使用魔杖。

在终端:</p>

brew install imagemagick@6
pip install wand

在蟒蛇中:

from wand.image import Image
pdf_file = '.../example/a.pdf'

def convert_pdf_to_jpg(file_name, pic_file, resolution=120):
    with Image(filename=file_name, resolution=resolution) as img:
        print('pages = ', len(img.sequence))
        with img.convert('jpeg') as converted:
            converted.save(filename=pic_file)
于 2018-05-31T12:07:30.013 回答
0

我发现 imagemagick 在 Linux 和 Windows 之间对色彩空间的转换处理存在重大差异。

使用命令

转换 -density 300 -colorspace RGB my.pdf my.jpg

转换 -density 300 -colorspace sRGB my.pdf my.jpg

在 Linux 中,-colorspace sRGB 和 -colorspace RGB 都生成图像,其中对比度和调色板是原始图像的主要转移,对比度增加并且颜色与原始图像相差甚远。

在 Windows 中,如果不完美,-colorspace sRGB 和 -colorspace RGB 都是可以接受的。

于 2018-09-08T11:46:51.560 回答
0

好的,这个问题与 imageMagick 无关。这是一个简单的彩色托盘问题。默认情况下将pdf转换为jpeg使用cmyk,而web标准是RGB

于 2018-01-05T14:20:39.400 回答