sda*_*aau 25 linux pdf imagemagick cmyk ghostscript
我很难将ImageMagick identify
用于识别PDF作为CMYK.
基本上,假设我正在构建此文件test.tex
,使用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}
Run Code Online (Sandbox Code Playgroud)
如果我然后尝试识别生成的test.pdf
文件,我将其作为RGB,无论我尝试过什么选项(至少根据源中的链接) - 然而,其中的颜色将保存为CMYK; 对于上面的来源:
$ 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)
...
Run Code Online (Sandbox Code Playgroud)
如果我也取消注释那\immediate\pdfobj stream ...
部分,那么同样的事情也会发生; 然而,如果文档中只有一种颜色(黑色),我看不出哪里identify
有RGB值的直方图(尽管可以说,它们都接近灰色)?
所以没关系,然后我尽管我最好尝试ghostscript
将其test.pdf
转换为新的pdf,这将被认为是CMYK identify
- 但即使在那里也没有运气:
$ 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
...
Run Code Online (Sandbox Code Playgroud)
因此,唯一identify
被认为是变化的东西Type: Grayscale
(来自之前Type: Palette
); 但否则它仍会看到RGB色彩空间!
与此相伴,注意identify
是能够正确上报CMYK PDF -见CMYK海报例如:安装PDF页面大小为(位图)图像尺寸?#17843 - TeX - LaTeX - Stack Exchange,用于使用convert
和生成此类PDF文件的命令行示例gs
.事实上,我们可以执行:
convert test.pdf -depth 8 -colorspace cmyk -alpha Off test-c.pdf
Run Code Online (Sandbox Code Playgroud)
...这将导致PDF将被identify
编辑为CMYK - 但是,PDF也将被栅格化(默认为72 dpi).
编辑:我刚刚发现,如果我在OpenOffice中创建.odp演示文稿,并将其导出为PDF; 默认情况下,PDF将是RGB,但是,以下命令(来自ghostscript示例| Production Monkeys):
# Color PDF to CMYK:
gs -dSAFER -dBATCH -dNOPAUSE -dNOCACHE -sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK -dProcessColorModel=/DeviceCMYK \
-sOutputFile=output.pdf input.pdf
Run Code Online (Sandbox Code Playgroud)
......实际上会产生一个CMYK pdf,identify
由此报告(尽管,黑色将是丰富的,而不是普通的 - 在所有四个频道上); 但是,此命令仅在幻灯片添加了图像时才起作用(显然,它是触发颜色转换的那个?!)!有趣的是,我无法从pdflatex
PDF中获得相同的效果.
所以我想我的问题可以通过两种方式提出:
identify
(并因此构建正确的CMYK颜色直方图)identify
,这将承认使用CMYK颜色,即使正确地在原来test.pdf
的pdflatex
(以及可能建立一个颜色直方图,基于任意选择的PDF页面上,就像identify
是应该)?提前感谢任何答案,
干杯!
一些参考:
它是否例如指定为"0 0 0 1 setcmykcolor"?或者可能更像是"0 0 0 setrgbcolor"?在后一种情况下,如果将DeviceRGB重新映射到基于CIE的色彩空间以便获得RGB图像颜色管理,则最终会出现丰富的黑色文本.
Kur*_*fle 26
sdaau,您用于尝试将PDF转换为CMYK的命令不正确.试试这个:
gs \
-o test-cmyk.pdf \
-sDEVICE=pdfwrite \
-sProcessColorModel=DeviceCMYK \
-sColorConversionStrategy=CMYK \
-sColorConversionStrategyForImages=CMYK \
test.pdf
Run Code Online (Sandbox Code Playgroud)
如果颜色转换不能按预期工作,并且如果您看到"无法将颜色空间转换为灰色,将策略还原为LeaveColorUnchanged"等消息,则...
在这种情况下,添加-dOverrideICC
到命令行并查看它是否根据需要更改结果.
正如@Marein评论的那样,如果你想避免出现在图像中的JPEG工件(之前没有),你应该添加
-dEncodeColorImages=false
Run Code Online (Sandbox Code Playgroud)
进入命令行.
(对于几乎所有的GS PDF-> PDF处理都是如此,不仅仅适用于这种情况.因为GS默认创建一个全新文件,包含新构造的对象和新文件结构,当被要求生成PDF输出时 - 它不会简单地重新使用以前的对象,更多的"哑" PDF处理器一样pdftk
不{ pdftk
还有其他的好处不过,别误会我的发言!} GS默认为使用JPEG压缩-看看当前PS2PDF文档和搜索"ColorImageFilter"了解更多细节......)
小智 6
我有一个无关的问题,但我目前也在与CMYK PDF格斗.
我在这里写了这个小脚本(它叫做pdf2pdfx):
#!/bin/bash
gs \
-dPDFX \
-dBATCH \
-dNOPAUSE \
-dNOOUTERSAVE \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK \
-dProcessColorModel=/DeviceCMYK \
-dPDFSETTINGS=/prepress \
-sOutputFile="${1%%.pdf}_X-3.pdf" \
PDFX_def.ps \
"$1"
Run Code Online (Sandbox Code Playgroud)
我的PDFX_def.ps包含以下内容(我删除了ICC配置文件并定义了FOGRA39,这应该没问题):
%!
% $Id$
% This is a sample prefix file for creating a PDF/X-3 document.
% Feel free to modify entries marked with "Customize".
% This assumes an ICC profile to reside in the file (ISO Coated sb.icc),
% unless the user modifies the corresponding line below.
systemdict /ProcessColorModel known {
systemdict /ProcessColorModel get dup /DeviceGray ne exch /DeviceCMYK ne and
} {
true
} ifelse
{ (ERROR: ProcessColorModel must be /DeviceGray or DeviceCMYK.)=
/ProcessColorModel cvx /rangecheck signalerror
} if
% Define entries to the document Info dictionary :
% /ICCProfile (/usr/share/color/icc/ISOcoated_v2_300_eci.icc) def % Customize or remove.
[ /GTS_PDFXVersion (PDF/X-3:2002) % Must be so (the standard requires).
/Title (Title) % Customize.
/Trapped /False % Must be so (Ghostscript doesn't provide other).
/DOCINFO pdfmark
% Define an ICC profile :
currentdict /ICCProfile known {
[/_objdef {icc_PDFX} /type /stream /OBJ pdfmark
[{icc_PDFX} <</N systemdict /ProcessColorModel get /DeviceGray eq {1} {4} ifelse >> /PUT pdfmark
[{icc_PDFX} ICCProfile (r) file /PUT pdfmark
} if
% Define the output intent dictionary :
[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark
[{OutputIntent_PDFX} <<
/Type /OutputIntent % Must be so (the standard requires).
/S /GTS_PDFX % Must be so (the standard requires).
/OutputCondition (Commercial and specialty printing) % Customize
/Info (none) % Customize
/OutputConditionIdentifier (FOGRA39) % Customize
/RegistryName (http://www.color.org) % Must be so (the standard requires).
currentdict /ICCProfile known {
/DestOutputProfile {icc_PDFX} % Must be so (see above).
} if
>> /PUT pdfmark
[{Catalog} <</OutputIntents [ {OutputIntent_PDFX} ]>> /PUT pdfmark
Run Code Online (Sandbox Code Playgroud)
然后识别正确报告CMYK颜色空间.之前:
tbart@blackknight ~/orpheus/werbung/action $ identify -verbose action_schulungsvideo_v3_print.pdf
Image: action_schulungsvideo_v3_print.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 612x859+0+0
Resolution: 72x72
Print size: 8.5x11.9306
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Depth: 16/8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Red:
min: 0 (0)
max: 65535 (1)
mean: 53873.6 (0.822058)
standard deviation: 19276.7 (0.294144)
kurtosis: 1.854
skewness: -1.82565
Green:
min: 0 (0)
max: 65535 (1)
mean: 55385.6 (0.84513)
standard deviation: 19274.6 (0.294112)
kurtosis: 2.09868
skewness: -1.91651
Blue:
min: 0 (0)
max: 65535 (1)
mean: 51020 (0.778516)
standard deviation: 20077.7 (0.306367)
kurtosis: 0.860627
skewness: -1.52344
Image statistics:
Overall:
min: 0 (0)
max: 65535 (1)
mean: 53426.4 (0.815235)
standard deviation: 19546.7 (0.298263)
kurtosis: 1.59453
skewness: -1.75701
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: rgb(223,223,223)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 612x859+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2011-09-14T15:38:57+02:00
date:modify: 2011-09-14T15:38:57+02:00
pdf:HiResBoundingBox: 612.283x858.898+0+0
pdf:Version: PDF-1.5
signature: 210bfc9cf90e3b9505385f8b2267da1665b5c2de28bb5223311afba01718bbeb
Artifacts:
verbose: true
Tainted: False
Filesize: 1.577MBB
Number pixels: 526KB
Pixels per second: 52.57MB
User time: 0.020u
Elapsed time: 0:01.009
Version: ImageMagick 6.6.5-6 2011-04-08 Q16 http://www.imagemagick.org
Run Code Online (Sandbox Code Playgroud)
后:
tbart@blackknight ~/orpheus/werbung/action $ pdf2pdfx action_schulungsvideo_v3_print.pdf
GPL Ghostscript 9.04 (2011-08-05)
Copyright (C) 2011 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
tbart@blackknight ~/orpheus/werbung/action $ identify -verbose action_schulungsvideo_v3_print_X-3.pdf
Image: action_schulungsvideo_v3_print_X-3.pdf
Format: PDF (Portable Document Format)
Class: DirectClass
Geometry: 612x859+0+0
Resolution: 72x72
Print size: 8.5x11.9306
Units: Undefined
Type: ColorSeparation
Base type: ColorSeparation
Endianess: Undefined
Colorspace: CMYK
Depth: 16/8-bit
Channel depth:
cyan: 8-bit
magenta: 8-bit
yellow: 8-bit
black: 8-bit
Channel statistics:
Cyan:
min: 0 (0)
max: 65535 (1)
mean: 8331.78 (0.127135)
standard deviation: 14902.2 (0.227392)
kurtosis: 1.62171
skewness: 1.7799
Magenta:
min: 0 (0)
max: 62194 (0.94902)
mean: 6739.34 (0.102836)
standard deviation: 14517.5 (0.221523)
kurtosis: 2.08183
skewness: 1.93276
Yellow:
min: 0 (0)
max: 65535 (1)
mean: 13310.1 (0.203098)
standard deviation: 17022.5 (0.259746)
kurtosis: 0.991135
skewness: 1.45216
Black:
min: 0 (0)
max: 56540 (0.862745)
mean: 7117.47 (0.108606)
standard deviation: 16803.7 (0.256408)
kurtosis: 3.02752
skewness: 2.16554
Image statistics:
Overall:
min: 0 (0)
max: 65535 (1)
mean: 8874.66 (0.135419)
standard deviation: 15850.6 (0.241864)
kurtosis: 2.17614
skewness: 1.88139
Total ink density: 292%
Rendering intent: Undefined
Interlace: None
Background color: white
Border color: cmyk(223,223,223,0)
Matte color: grey74
Transparent color: black
Compose: Over
Page geometry: 612x859+0+0
Dispose: Undefined
Iterations: 0
Compression: Undefined
Orientation: Undefined
Properties:
date:create: 2011-09-14T15:39:30+02:00
date:modify: 2011-09-14T15:39:30+02:00
pdf:HiResBoundingBox: 612.28x858.9+0+0
pdf:Version: PDF-1.3
signature: 0416db7487ea147b974ece5748bc4284e82bfc3fb7cd07a4de050421ba112076
Artifacts:
verbose: true
Tainted: False
Filesize: 2.103MBB
Number pixels: 526KB
Pixels per second: 5.25708PB
User time: 0.000u
Elapsed time: 0:01.000
Version: ImageMagick 6.6.5-6 2011-04-08 Q16 http://www.imagemagick.org
Run Code Online (Sandbox Code Playgroud)
这是64位Gentoo与gs 9.04也许这有帮助吗?
源PDF源于inkscape pdf导出,颜色仅限于ECI ISO涂层v2中涵盖的颜色.我使用它作为缺乏CMYK导出inkscape和缺乏印前准备PDF/X输出的解决方法......