我刚刚开始学习postscript,并且我一直在创建PDF(应该在CMYK中)并插入图像。如何使用postscript将CMYK图像插入到PDF中
但是,我搜索并搜索了互联网,并下载了尽可能多的Postscript手册,而没有举出一个简单的例子(请纠正我,如果我错过了任何)。
所以,我的问题是我有一个CMYK图像,我希望它嵌入在我的PDF中。但是,当我使用基于RGB图像的简单示例插入图片时,图片变为负值(我改变了我认为适合CMYK图片的内容)
下面是我用作我的pdf创建的内容。
%!
/Times-Roman findfont 14 scalefont setfont
<< /PageSize [419.528 595.276] >> setpagedevice
% MM to Units
% [ W x H ]
/DeviceCMYK setcolorspace
% Page 1
%
% Set the Original to be the top left
%
0 595.276 translate
1 -1 scale
gsave
%
% Save this state before moving x y specifically for images
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Image 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% set the X and Y of the mask here
-8.5039 140.21007874 translate %Top Left Coordinates of mask
/box {
newpath
moveto
436.535433071 0 rlineto % width of the mask
0 463.569448819 rlineto % height of the mask %Top Left Coordinates
-436.535433071 0 rlineto
closepath
} def
0 0 box % Set up our box
clip % Clip to the box
% DO NOT reset the document to original position
% as we want the translate to be relative to the clipped box
%
%grestore * Do not use here
%gsave * Do not use here
%
%% Images when flipped to draw correctly are scaled UPWARDS
%% so you need to move the x,y position to the bottom left
-1.44 621.714330709 translate % Bottom Left Cordinates
% unset the mirror or the image will be flipped!
1 -1 scale
% scale the image
438.000944882 657.119055118 scale %%% Need to work out size and width into Units
1825 % number of columns per row %width of the image %%%% IN PIXELS!
2738 % number of rows %height of the images %%%% IN PIXELS!
8 % bits per color channel (1, 2, 4, or 8)
[1825 0 0 -2738 0 2738] % transform array... maps unit square to pixel
(cmyk_image.jpg) (r) file /DCTDecode filter % opens the file and filters the image data
false % pull channels from separate sources
4
colorimage
%%%%%
% End of Image 1
%%%%%
showpage
我试着看viewjpeg.ps,但我想要插入到PS中的图像,而不是通过命令行插入。
非常感谢
编辑:形象问题:)(它通过wetransfer是由于其大小和CMYK色彩空间)
再次编辑:
我已经调整了代码再次使用字典(根据您的文章KenS Simple Image Dictionary)。
<< /PageSize [419.528 595.276] >> setpagedevice
0 595.276 translate
1 -1 scale
-1.44 621.714330709 translate % Bottom Left Cordinates
% unset the mirror or the image will be flipped!
1 -1 scale
% scale the image
438.000944882 657.119055118 scale %%% Need to work out size and width into Units
/OneComponentString (cmyk_image.jpg) (r) file /DCTDecode filter def
/OneComponentImage1
{
<<
/ImageType 1
/Width 1825
/Height 2738
/ImageMatrix [1825 0 0 -2738 0 2738]
/BitsPerComponent 8
/DataSource OneComponentString
>>
} bind def
gsave
/DeviceCMYK setcolorspace
OneComponentImage1 image
grestore
showpage
但是它仍然快到了负(我explicily leftout的/解码[0 1]从字典,因为这是扔了以下错误:
Error: /rangecheck in --image--
Operand stack:
--dict:7/7(L)--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1951 1 3 %oparray_pop 1950 1 3 %oparray_pop 1934 1 3 %oparray_pop 1820 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1847 1 3 %oparray_pop
Dictionary stack:
--dict:1183/1684(ro)(G)-- --dict:0/20(G)-- --dict:80/200(L)--
Current allocation mode is local
Last OS error: Invalid argument
所以,我觉得我越来越近了。可能有人解释的解码方案,以及为什么它使用CMYK图像时可能抛出了一个错误?
非常感谢。
嗨肯,谢谢你的回应。 我有的手册是: https://www.adobe.com/products/postscript/pdfs/PLRM.pdf http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF https: //staff.science.uva.nl/ajpheck/Courses/Mastercourse2005/tutorial.pdf 如果你有更多的指针,那将是惊人的! 是的viewjpeg确实工作 - 我认为我的问题是我发现很难简化该脚本。 感谢关于压缩的提示 - scipt需要记住高分辨率图像(300 dpi)。 我会看看我是否可以向你提供我所指的图像。 – MissAran
红色和蓝色书籍是一个很好的起点,如果你打算对字体做任何事情(但它绝对不是必需的),你可能会喜欢看黑白书。如果您打算使用PDF,那么PDF参考或其ISO版本是值得的。另外,不是手册而是推荐,请看看Acumen Training的网站和Acumen Journal。 PostScript和PDF的绝佳资源。 http://www.acumentraining.com/acumenjournal.html – KenS