开发者

Calculate CMYK coverage on PDF

开发者 https://www.devze.com 2023-01-04 03:01 出处:网络
I don\'t suppose is there any free or open source libraries out there that able to calculate the CMYK coverage on a pdf file. I tried loo开发者_StackOverflowking around I don\'t seem to able to find a

I don't suppose is there any free or open source libraries out there that able to calculate the CMYK coverage on a pdf file. I tried loo开发者_StackOverflowking around I don't seem to able to find any. If there isn't any out there if anyone could point me in the right direction of what do I need to do in order to calculate the CYMK coverage on a pdf. Oh also the development environment I'd be working in is .net framework 4.0

Cheers


OK, there is a new option now (since a few days ago) with Ghostscript for all those who are willing to compile it from the source. It is still 'bleeding edge', and not recommended for productive use. The rest of you will have to wait for the next official release.

The new option comes in the shape of a new 'device' called inkcov. This works similar to the 'bbox' device which spits out the BoundingBox values for each page: the 'inkcov' device spits out the C, M, Y and K values of ink coverage used for each page (a value of 1 corresponds to 100%). Be aware that the total sum of ink may be higher than 100% (like: mixing 100% of Yellow with 100% of Magenta gives the optical impression of 100% 'Red').

Try this command with a Ghostcript compiled from current Git source:

gs -o - -sDEVICE=inkcov /path/to/your.pdf

This will spit out an output similar to this one:

Page 1
 0.20898  0.20905  0.41320  0.55001 CMYK OK
Page 2
 0.33561  0.02026  0.21677  0.16750 CMYK OK
Page 3
 0.00000  0.00000  0.00000  1.00000 CMYK OK
[....]

This little utility has been created by Sebastian Kapfer from the University of Erlangen and contributed to the Ghostscript source code. (Of course, it's still awaiting some heavy testing and verification, comparing its results to other similar tools.)


You can use Ghostscript. Run it with the tiffsep or tiffsep1 device at 72dpi resolution. This will create separate TIFF files for each CMYK colorant which you can then further use to 'count' the coverage for each color:

gswin32c.exe ^
    -sDEVICE=tiffsep ^
    -r72x72 ^
    -o "c:/path/to/output/dir/page_%03d.tif" ^
    c:/path/to/input.pdf

This device creates multiple output files. It creates:

  1. one 32bit composite CMYK file (tiff32nc format, which is 32bit CMYK [8bits/component]), plus
  2. multiple tiffgray files -- a tiffgray (which is 8bit gray, LZW compressed) for each color separation.

The tiffgray files are LZW compressed. The -sOutputFile=...-specified filename will be the CMYK file. Names of separation 'tiffgray' files for CMYK colorants will have appended '.Cyan.tif', '.Magenta.tif' '.Yellow.tif' and '.Black.tif' to that name. tiffsep also recognizes spot colors automatically and creates additional tiffgray separations for them; the names of these have a number appended. (You can also pre-determine the names by passing -sSeparationColorNames on the commandline -- but you better read up the details in Ghostscript's documentation, file Devices.htm).

If you use the tiffsep1 output device, the result will be similar -- the difference is that you will get only the gray separations (no 32bit composite CMYK), but these will be TIFF G4 files (G4 compression scheme).

You can change the compression scheme by adding -sCompression=lzw (or one of none | crle | g3 | g4 | pack). Be aware that using =none for compression will create files of equal sizes for each separation colorant.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号