Converting PDF to CMYK (with identify recognizing CMYK)

后端 未结 5 1911
眼角桃花
眼角桃花 2020-12-02 06:19

I am having much trouble to get ImageMagick\'s identify to, well, identify a PDF as CMYK.

Essentially, let\'s say I\'m building this file, test.t

5条回答
  •  庸人自扰
    2020-12-02 06:44

    I have an unrelated problem but I am also struggling with CMYK PDFs currently.

    I wrote this little script here (it's called 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"
    

    and my PDFX_def.ps contains the following (I removed the ICC profile and defined FOGRA39, this should be OK):

    %!
    % $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} <> /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} <> /PUT pdfmark
    

    Identify then correctly reports CMYK colorspace. Before:

    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
    

    after:

    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
    

    This is on 64bit Gentoo with gs 9.04 Maybe that helps?

    Source PDF stems from inkscape pdf export, colors were restricted to those covered in ECI ISO coated v2. I use this as a workaround for the lacking CMYK export of inkscape and the lacking prepress-ready PDF/X output...

提交回复
热议问题