将PDF转换为CMYK(识别识别CMYK) [英] Converting PDF to CMYK (with identify recognizing CMYK)
问题描述
我很难让ImageMagick的识别
,以便将PDF标识为CMYK。
I am having much trouble to get ImageMagick's identify
to, well, identify a PDF as CMYK.
基本上,假设我正在构建此文件, test.tex
, pdflatex
:
Essentially, let's say I'm building this file, test.tex
, with pdflatex
:
\documentclass[a4paper,12pt]{article}
%% https://tex.stackexchange.com/questions/13071
\pdfcompresslevel=0
%% http://compgroups.net/comp.text.tex/Making-a-cmyk-PDF
%% ln -s /usr/share/color/icc/sRGB.icm .
% \immediate\pdfobj stream attr{/N 4} file{sRGB.icm}
% \pdfcatalog{%
% /OutputIntents [ <<
% /Type /OutputIntent
% /S/GTS_PDFA1
% /DestOutputProfile \the\pdflastobj\space 0 R
% /OutputConditionIdentifier (sRGB IEC61966-2.1)
% /Info(sRGB IEC61966-2.1)
% >> ]
% }
%% http://latex-my.blogspot.com/2010/02/cmyk-output-for-commercial-printing.html
%% https://tex.stackexchange.com/questions/9961
\usepackage[cmyk]{xcolor}
\begin{document}
Some text here...
\end{document}
如果我然后尝试识别结果 test.pdf
文件,无论我尝试过什么选项(至少根据源代码中的链接),我都把它作为RGB,然而,它的颜色将是保存为CMYK;对于上面的来源:
If I then try to identify the resulting test.pdf
file, I get it as RGB, no matter what options I've tried (at least according to the links in the source) - and yet, the colors in it would be saved as CMYK; for the source above:
$ grep -ia 'cmyk\|rgb\| k' test.pdf
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
0 0 0 1 k 0 0 0 1 K
FontDirectory/CMR12 known{/CMR12 findfont dup/UniqueID known{dup
/PTEX.Fullbanner (This is pdfTeX, Version 3.1415926-1.40.11-2.2 (TeX Live 2010) kpathsea version 6.0.0)
$ identify -verbose 'test.pdf[0]'
...
Type: Palette
Endianess: Undefined
Colorspace: RGB
Depth: 16/8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
...
Green:
...
Blue:
...
Histogram:
5: (12593,11565,11822) #31312D2D2E2E rgb(49,45,46)
4: (16448,15420,15677) #40403C3C3D3D rgb(64,60,61)
9: (20303,19275,19532) #4F4F4B4B4C4C rgb(79,75,76)
25: (23901,23130,23387) #5D5D5A5A5B5B rgb(93,90,91)
...
如果我还取消注释,那么同样的事情也会发生 \immediate\pdfobj stream ...
part;然而,如果文档中只有一种颜色(黑色),我看不到识别
在哪里提出RGB值的直方图(尽管可以说,所有这些都接近灰色)?!
The same pretty much happens if I also uncomment that \immediate\pdfobj stream ...
part; and yet, if there is only one color (black) in the document, I don't see where does identify
come up with a histogram of RGB values (although, arguably, all of them close to gray) ?!
所以没关系,然后我会尽量使用 ghostscript
将 test.pdf
转换为新的pdf,通过识别将其识别为CMYK
- 但即使在那里也没有运气:
So nevermind this, then I though I'd better try to use ghostscript
to convert the test.pdf
into a new pdf, which would be recognized as CMYK by identify
- but no luck even there:
$ gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=test-gs.pdf -dUseCIEColor -sProcessColorModel=DeviceRGB -dProcessColorModel=/DeviceCMYK -sColorConversionStrategy=/CMYK test.pdf
GPL Ghostscript 9.01 (2011-02-07)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
$ identify -verbose 'test-gs.pdf[0]'
...
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: RGB
Depth: 16/8-bit
...
所以识别
唯一被认为是变化的东西,是类型:灰度
(来自之前的类型:调色板
);但是否则它仍会看到RGB颜色空间!
So the only thing that identify
perceived as a change, is Type: Grayscale
(from previous Type: Palette
); but otherwise it still sees an RGB colorspace!
除此之外,请注意标识
是能够正确报告CMYK pdf - 请参阅 CMYK海报示例:将pdf页面大小拟合为(位图)图像大小? #17843 - TeX - LaTeX - Stack Exchange ,用于使用 convert
和 gs $生成此类PDF文件的命令行示例C $ C>。事实上,我们可以执行:
Along with this, note that identify
is capable of correctly reporting a CMYK pdf - see CMYK poster example: fitting pdf page size to (bitmap) image size? #17843 - TeX - LaTeX - Stack Exchange for a command line example of generating such a PDF file using convert
and gs
. In fact, we can execute:
convert test.pdf -depth 8 -colorspace cmyk -alpha Off test-c.pdf
...此 会产生一个PDF <$ strong c $ c>识别编辑为CMYK - 但是,PDF也将被栅格化(默认为72 dpi)。
... and this will result with a PDF that will be identify
ed as CMYK - however, the PDF will also be rasterized (default at 72 dpi).
编辑:我刚刚发现,如果我在OpenOffice中创建.odp演示文稿,并将其导出为PDF;默认情况下,PDF将是RGB,但是,以下命令(来自 ghostscript Examples | Production Monkeys ):
I have just discovered, that if I create an .odp presentation in OpenOffice, and export it to PDF; that PDF will by default be RGB, however, the following command (from ghostscript Examples | Production Monkeys):
# Color PDF to CMYK:
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK \
-sOutputFile=output.pdf input.pdf
...实际上会产生一个CMYK pdf,由识别
报告(尽管黑色会很丰富,而不是普通的 - 在所有四个频道上);但是,当幻灯片添加了图像时,此命令将仅 (显然,它是触发颜色转换的那个?!)!有趣的是,我无法从 pdflatex
PDF获得相同的效果。
... actually will produce a CMYK pdf, reported as such by identify
(although, the black will be rich, not plain - on all four channels); however, this command will work only when the slide has an added image (apparently, it is the one triggering the color conversion?!)! Funnily, I cannot get the same effect from a pdflatex
PDF.
所以我想我的问题可以通过两种方式询问:
So I guess my question can be asked two ways:
- Linux中是否存在任何命令行转换方法,它们会将RGB pdf转换为CMYK pdf,同时保留向量,这在<$ c $中被识别为c>识别(并因此构建正确的CMYK颜色直方图)
- 是否还有其他类似于
的命令行Linux工具识别
,即使在pdflatex $ c $的原始
test.pdf
中也能正确识别CMYK颜色的使用c>(并且可能构建一个颜色直方图,基于任意选择的PDF页面,如识别
应该)?
- Are there any command-line conversion methods in Linux, that will convert an RGB pdf into a CMYK pdf while preserving vectors, which is recognized as such in
identify
(and will consequently build a correct histogram of CMYK colors) - Are there any other command-line Linux tools similar to
identify
, which would recognize use of CMYK colors correctly even in the originaltest.pdf
frompdflatex
(and possibly build a color histogram, based on an arbitrarily chosen PDF page, likeidentify
is supposed to)?
预先感谢您的回答,
干杯!
Thanks in advance for any answers,
Cheers!
  ;
一些参考:
- adobe - 脚本(或其他一些方法)将RGB转换为CMYK的PDF格式? - Stack Overflow
- 颜色 - PDF颜色模型和LaTeX - TeX - LaTeX - Stack Exchange
- color - xcolor包的选项cmyk不生成CMYK PDF - TeX - LaTeX - Stack Exchange
- 制作cmyk PDF - comp.text.tex |计算机组
- 与ghostscript的颜色管理? - Rhinocerus :
- adobe - Script (or some other means) to convert RGB to CMYK in PDF? - Stack Overflow
- color - PDF colour model and LaTeX - TeX - LaTeX - Stack Exchange
- color - Option cmyk for xcolor package does not produce a CMYK PDF - TeX - LaTeX - Stack Exchange
- Making a cmyk PDF - comp.text.tex | Computer Group
- colormanagement with ghostscript ? - Rhinocerus:
例如是否指定为0 0 0
1 setcmykcolor?或者可能更像是0 0 0 setrgbcolor?在
后一种情况下,如果DeviceRGB是
重新映射到基于CIE的颜色空间,为了获得RGB图像颜色
管理,你最终会得到一个丰富的黑色文本。
Is it for instance specified as "0 0 0 1 setcmykcolor"? Or possibly rather as "0 0 0 setrgbcolor"? In the latter case you would end up with a rich black for text, if DeviceRGB is remapped to a CIE-based color space in order to get RGB images color managed.
推荐答案
sdaau,您尝试使用的命令将您的PDF转换为CMYK是不正确的。试试这个:
sdaau, the command you used for trying to convert your PDF to CMYK was not correct. Try this one instead:
gs \
-o test-cmyk.pdf \
-sDEVICE=pdfwrite \
-sProcessColorModel=DeviceCMYK \
-sColorConversionStrategy=CMYK \
-sColorConversionStrategyForImages=CMYK \
test.pdf
更新
如果颜色转换无法正常工作,如果您看到无法将色彩空间转换为灰色,将策略还原为LeaveColorUnchanged等消息,那么......
Update
If color conversion does not work as desired and if you see a message like "Unable to convert color space to Gray, reverting strategy to LeaveColorUnchanged" then...
- 您的Ghostscript可能是 9.x版本系列中的较新版本,而
- 您的源PDF可能会使用嵌入式 ICC颜色配置文件
- your Ghostscript probably is a newer release from the 9.x version series, and
- your source PDF likely uses an embedded ICC color profile
在这种情况下添加 -dOverrideICC
到命令行,看看它是否会根据需要更改结果。
In this case add -dOverrideICC
to the command line and see if it changes the result as desired.
正如@Marein评论的那样,如果你想避免d出现在图像中的JPEG工件(之前没有),你应该添加
As @Marein commented, if you want to avoid JPEG artifacts appearing in the images (where there were none before), you should add
-dEncodeColorImages=false
进入命令行。
(对于几乎所有GS PDF-> PDF 处理都是如此,不仅仅是针对这种情况。因为GS默认创建一个全新的当被要求生成PDF输出时,文件包含新构造的对象和新的文件结构 - 它不仅仅是重复使用以前的对象,而是像 pdftk $ c这样更哑的PDF处理器$ c> {
pdftk
还有其他优点,不要误解我的陈述!} 。默认情况下GS应用JPEG压缩 - 看看当前 Ps2pdf文档 并搜索ColorImageFilter以了解更多详情......)
(This is true for almost all GS PDF->PDF processing, not just for this case. Because GS by default creates a completely new file with newly constructed objects and a new file structure when asked to produce PDF output -- it doesn't simply re-use the previous objects, as a more "dumb" PDF processor like pdftk
does {pdftk
has other advantages though, don't misunderstand my statement!}. GS applies JPEG compression by default -- look at the current Ps2pdf documentation and search for "ColorImageFilter" to learn about more details...)
这篇关于将PDF转换为CMYK(识别识别CMYK)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!