• | New Account
  • | Log In [x]
  • | Forgot Password Login: [x]
  • Format For Printing
  •  -  XML
  •  -  Clone This Bug
  •  -  Top of page

Search code, repositories, users, issues, pull requests...

Provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications

Experiments with Color Management (Ghostscript 9.27, pdf output)

i3v/GS_ColorManagement_and_pdfOutput

Name already in use.

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more about the CLI .

  • Open with GitHub Desktop
  • Download ZIP

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

A while ago, I've performed some related experiments, trying to get how color management works in Ghostscript 9.27 for pdf output. This gist aims to provide some reproducible examples of gs behaviour. Related to this SO question.

The example input used here is a simple pdf (no built-in profiles), that contains:

  • Column1 is RGB image (DeviceRGB = no built-in profile, no colorimetrically defined colorspace)
  • Column2 is a set of a table cells filled with the same RGB colors
  • Column3 is a set of a table cells filled with somewhat-close CMYK colors (converted as sRGB->RSWOP)
  • all the same
  • small transparent tikz pic

Input pdf screenshot

  • Its source tex code is attached ( same in overleaf ).
  • Built with XeLaTeX from TexLive 2018.
  • The arrow shows the point, where I click to make Output Preview -> Object Inspector show something.

Other inputs

For these experiments, I also use (included in this repo as well):

  • the "Perceptual" rendering intent (0) outputs cyan only,
  • the "RelativeColorimetric" intent (1) outputs magenta only
  • and "Saturation" intent (2) outputs yellow only.
  • gs/lib/PDFX_def.ps from the Ghostscript repo, modified to utilize cmyk_des_renderintent.icc . A prefix file for creating PDF/X-3.

Types of built-in profiles

At least two things that might be called "embedded profile":

  • whole-file "Output intent profile" (used in PDF/X-3)
  • object-specific ICC based colorspace, defined via a profile (e.g. in embedded sRGB image)

Ghostscript (9.12-9.27, not sure about earlier) supports PDF/X-3 output . As a part of it, there is a possibility to embed an "output intent" icc profile.

Let's start from the following (same in conv_v1.bat ):

Here's how the resulting "colorbar_v1.pdf" (attached) looks like in Foxit reader 9.5 (it ignores output intent):

ghostscript pdfa outputintent

Here's how the same file looks like in Adobe Acrobat DC (it takes output intent into account):

ghostscript pdfa outputintent

The same file looks different in two different viewers because the "Output Intent" icc profile is applied by the viewer, during pdf rendering. The output intent profile is also visible in Adobe Preflight:

ghostscript pdfa outputintent

Few more details about what's actually happening here:

  • gswin64c is Windows CLI-only version of the gs. Use just gs on linux, the rest is the same.
  • -dHaveTransparency=false makes sure that the 2nd page would get rasterized (due to the presence of a tikz pic with transparency)
  • -r20 makes sure rasterization would be clearly visible (due to just 20dpi)
  • This demonstrates that some color conversion is possible, but... only where rasterization happens. (Compare with "Exp 3t" below)
  • Note that OutputICCProfile parameter is not mentioned in current docs , since this ( 9.27 docs are a bit outdated).
  • RenderIntent is also undocumented. It only affects rasterization as well.
  • -dDefaultRenderingIntent=/Perceptual puts said intent to metadata, alongside "Output Intent icc profile" (which is specified in PDFX_IntCmyk.ps ), without affecting any stored color values. This makes Acrobat draw everything in cyan.
  • -dProcessColorModel=/DeviceCMYK is required, but only valid choice is /DeviceCMYK , due to -sOutputICCProfile="cmyk_des_renderintent.icc" . (When -sColorConversionStrategy=UseDeviceIndependentColor , -dProcessColorModel would control whether the second page would be ICCBasedRGB or ICCBasedCMYK , if we drop other conflicting options. This would slightly affect colors we get there.)
  • -sDefaultRGBProfile="default_rgb.icc" is a placeholder for possible experiments with input icc profiles (they generally work OK). Same default is set if this parameter is omitted.

Exp 2 (CMYK)

The following is a naive modification of the first command, attempting to convert everything to CMYK (same in conv_v2.bat ):

This produces a very different result - now there's just some "saturation adjustment" visible in both Acrobat (more saturated) and Foxit (less saturated).

Note that dProcessColorModel is still required here (despite of note 6 ), see this .

ghostscript pdfa outputintent

Exp 3 (CMYK, not PDF/X-3)

Now we know the effect of the PDFX_IntCmyk.ps . Let's check the result without it (same in conv_v3.bat ):

ghostscript pdfa outputintent

Acrobat now shows the same as Foxit - now there's no "output intent" profile. Both results now look much like the original, even the rasterized part (except that it's low-res). The sOutputICCProfile has no effect.

Exp 3t (CMYK, not PDF/X-3, tiff)

Now, let's do the same for tiff output, where -sOutputICCProfile is honored (same in conv_v3t.bat ):

ghostscript pdfa outputintent

Exp 4 (just ICCBased)

Just for reference, let's convert to "DeviceIndependent" (ICCBased) colors, without mentioning any output profiles:

ghostscript pdfa outputintent

Exp 5 (not PDF/X-3)

Like "Exp 1", but without PDF/X-3:

ghostscript pdfa outputintent

Exp AA1 (Acrobat, embed profile)

ghostscript pdfa outputintent

Exp AA2 (Acrobat, not embed profile)

ghostscript pdfa outputintent

  • This makes colors "colorimetrically defined", and means that " some icc profile is embedded" (see Adobe Preflight screenshots, especially in Exp 4).
  • The "how are colors converted?" and "how do I adjust parameters of this conversion?" are, in a general case, far trickier questions.
  • Acrobat embeds the profile, selected by user and actually converts colors using it. Ghostscript is unable to do that.
  • The "Output intent profile" works as expected. AFAIU, it requires -sColorConversionStrategy=UseDeviceIndependentColor .
  • The -sOutputICCProfile does not work for pdf the way it works for tiff. It is undocumented here. (But it still affects pages being rasterized, when converting to DeviceIndependent colors. Not sure if it's a bug or a feature.)
  • There's no simple way to, say, avoid color clipping (by specifying intent), when converting from DeviceRGB to DeviceCMYK . Acrobat, with "embed profile" unchecked, allows to produce a DeviceCMYK file, with colors converted according to the specified icc profile. Ghostscript is unable to do that.

Final notes

gs simply ignores unknown switches.

icc profiles contain independent local_value->ICC and ICC->local_value tables. Compare cmyk_des_renderintent.icc and cmyk_src_renderintent.icc from this folder (e.g. with ICC Profile Inspector ).

Docs do warn, that only a small subset of color management options is supported for pdf output. You can only set default input color profile (e.g. for objects that do not have a profile), but you cannot set: output ICC profile, black generation options, etc.

DeviceRGB color values are passed unchanged. If a user needs a non trivial color adjustment, a non trivial DefaultRGB color space must be defined. Transfer functions and halftone phases are skipped.
  • The 2nd sentence here is probably be related to files in gs\Resource\ColorSpace folder. This might be the clue to at least some limited color management capabilities for related color conversions. I've never tried that.
  • The 1st and the 3rd sentences, probably, explain why we see no color conversions (nothing like what Acrobat produces)
  • In the docs, these 3 sentences seem to be related to -dPDFX , but, actually, the seem to be true for all cases.
  • Batchfile 34.0%
  • PostScript 22.3%

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How to create a correct (grayscale) PDF/X-3 file using Ghostscript

I’m trying to convert arbitrary PDF files (a magazine created with pdfLaTeX, containing some photos, but also some graphics such as webcomics) to valid PDF/X-3 using Ghostscript and I want the result to be in grayscale/monochrome. I don’t know a lot about ICC color profiles and I don’t really care about color management in any case, so if this easier without ICC profiles, then I don’t mind. I’m willing to let the printer do their thing with my file – I don’t need absolute color fidelity (especially since we’re talking about grayscale here).

I’ve been trying to get it to work using the Ghostscript documentation, section “Creating a PDF/X-3 document” . Based on that, my attempt looks like this:

Where my_pdfx_def.ps contains the following, based on the template that comes with Ghostscript:

This does run and produces a file that superficially seems OK in my PDF viewer. However, I’m not sure that this is actually enough (producing a valid/sensible PDF/X-3 document) considering the long list of things I’m supposed to do according to Ghostscript’s documentation. In particular, it says

To create a PDF/X-3 document from a Postscript or a PDF file, you should : […] Specify a PDF/X definition file before running the input document. It provides additional information to be included into the output document. A sample PDF/X definition file may be found in gs/lib/PDFX_def.ps . If a registered printing condition is applicable, specify its identifier in the PDF/X definition file. Otherwise provide an ICC profile and specify it in the PDF/X definition file as explained below.

I tried adapting the file PDFX_def.ps it mentions (see above), but I don’t know what an OutputCondition is or what I’m supposed to put for that. Unfortunately, this is barely documented in the Ghostscript docs. I tried setting an .icc file in my customized version, but couldn’t get Ghostscript to find that file – no matter what, I always got “ Error: /invalidfileaccess in --file-- ”. And which color profile would I be using, anyway?

Provide a DefaultRGB resource file in the ColorSpace resource category. Either define it in the PDF/X definition file, or provide a definition of gs/Resource/ColorSpace/DefaultRGB . gs/Resource/ColorSpace/DefaultRGB is usually distributed with Ghostscript, its content may not necessarily satisfy your needs, see below.

Needless to say, it doesn’t specify how to do this. But in any case, do I even need this considering I want grayscale?

Specify, using -sOutputICCProfile , an ICC profile which represents the color space (either CMYK or Gray) of the final file. This is the same ICC profile used in the PDF/X definition file as the ICCProfile. Even if you are using a standard OutputCondition and do not need to specify an ICCProfile, you must still set OutputICCProfile with an appropriate ICC profile in order for proper color conversion.

Well, I didn’t specify -sOutputICCProfile and that didn’t seem to do any harm. Should I still? (Again, where am I supposed to pull the ICC profile out from?)

  • ghostscript
  • color-profiles

fixer1234's user avatar

  • I tried your code but had to add -I ./ in the gs command to fix the /invalidfileaccess in --file-- error. –  shabbychef Aug 3, 2020 at 6:15

You must log in to answer this question.

Browse other questions tagged pdf ghostscript color-profiles icc ..

  • The Overflow Blog
  • Is AI enough to increase your productivity?
  • Featured on Meta
  • If more users could vote, would they engage more? Testing 1 reputation voting...
  • Practical effects of the October 2023 layoff

Hot Network Questions

  • How much of the surface of other planets is lit by the sun?
  • Did Sauron put his soul/spirit into all of the Rings of Power?
  • Animal Farm and the Porcine Penitentiary
  • Primeable numbers
  • Does using a preposition phrase instead of a direct object change the transitivity of a verb?
  • Can I fly to Puerto Rico with temporary (paper, with picture) driver's license?
  • Is it possible to replace/regear the front cog? My easiest gear is too easy and I want to try for a higher resistance
  • How is using Lua in a Context document different or easier than using Lua in Lualatex document?
  • When Friday asks Robinson "Why God no kill the devil", why can't Robinson find a proper answer?
  • Role of と in 必要とします
  • Fleo is a transitive verb?
  • Is our outsourced software vendor "Agile" or do they just not want to plan things?
  • Unix time, leap seconds, and converting Unix time to a date
  • How can I draw sequence of these fractal squares?
  • What is the purpose of being tried by a "jury of your peers"?
  • What a green X means in QGIS
  • How much more damage can a big cannon do to a ship than a small one?
  • Does Grover's algorithm really threaten symmetric cryptography?
  • Putting stones into bags
  • Connecting flight from Pakistan to Abu Dhabi to Thailand
  • Can support of GPL software legally be done in such a way as to practically force you to abandon your GPL rights?
  • Why does it seem the inner curls within a surface always cancels in order for greens theorem to be true
  • Remove decimal point in ScientificForm
  • Movie about an alien who overtakes different persons

ghostscript pdfa outputintent

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

ps2pdf : PostScript-to-PDF converter

Table of contents.

Overview Usage Setting page orientation Options Creating a PDF/X-3 document Creating a PDF/A document Limitations Ghostscript PDF Printer Description Known problems Comparison of ps2pdf and Acrobat Distiller Acknowledgments
ps2pdf [options] input.[e]ps output.pdf
ps2pdf input.[e]ps
ps2pdf input.[e]ps input.pdf

Setting page orientation

Parameter name      Notes    default    screen    ebook    printer    prepress AlwaysEmbed (13) [ ] = = = = AntiAliasColorImages (0) false = = = = AntiAliasGrayImages (0) false = = = = AntiAliasMonoImages (0) false = = = = ASCII85EncodePages false = = = = AutoFilterColorImages (1) true = = = = AutoFilterGrayImages (1) true = = = = AutoPositionEPSFiles (0) true = = = = AutoRotatePages /PageByPage /PageByPage /All /None /None Binding (0) /Left = = = = CalCMYKProfile (0) () = = = = CalGrayProfile (0) () = = = = CalRGBProfile (0) () = = = = CannotEmbedFontPolicy (0) /Warning /Warning /Warning /Warning /Error ColorACSImageDict (13) (note 7) (note 10) (note 10) (note 8) (note 9) ColorConversionStrategy (0 , 6) /LeaveColorUnchanged /sRGB /sRGB /UseDeviceIndependentColor /LeaveColorUnchanged ColorImageDepth -1 = = = = ColorImageDict (13) (note 7) = = = = ColorImageFilter /DCTEncode = = = = ColorImageDownsampleThreshold 1.5 = = = = ColorImageDownsampleType (3) /Subsample /Average /Bicubic /Bicubic /Bicubic ColorImageResolution 72 72 150 300 300 CompatibilityLevel 1.4 1.3 1.4 1.4 1.4 CompressPages true = = = = ConvertCMYKImagesToRGB false = = = = ConvertImagesToIndexed (0) false = = = = CoreDistVersion 4000 = = = = CreateJobTicket (0) false false false true true DefaultRenderingIntent /Default = = = = DetectBlends (0) true = = = = DoThumbnails (0) false false false false true DownsampleColorImages false true true false false DownsampleGrayImages false true true false false DownsampleMonoImages false true true false false EmbedAllFonts true false true true true EmitDSCWarnings (0) false = = = = EncodeColorImages true = = = = EncodeGrayImages true = = = = EncodeMonoImages true = = = = EndPage (0) -1 = = = = GrayACSImageDict (13) (note 7) (note 7) (note 10) (note 8) (note 9) GrayImageDepth -1 = = = = GrayImageDict (13) (note 7) = = = = GrayImageDownsampleThreshold 1.5 = = = = GrayImageDownsampleType (3) /Subsample /Average /Bicubic /Bicubic /Bicubic GrayImageFilter /DCTEncode = = = = GrayImageResolution 72 72 150 300 300 ImageMemory (0) 524288 = = = = LockDistillerParams false = = = = LZWEncodePages (2) false = = = = MaxSubsetPct 100 = = = = MonoImageDepth -1 = = = = MonoImageDict (13) <<K -1>> = = = = MonoImageDownsampleThreshold 1.5 = = = = MonoImageDownsampleType /Subsample /Average /Bicubic /Bicubic /Bicubic MonoImageFilter /CCITTFaxEncode = = = = MonoImageResolution 300 300 300 1200 1200 NeverEmbed (13) (note 11) (note 12) (note 11) (note 12) (note 11) (note 12) [ ] (note 12) [ ] (note 12) OffOptimizations 0 = = = = OPM 1 = = = = Optimize (0 , 5) false true true true true ParseDSCComments true = = = = ParseDSCCommentsForDocInfo true = = = = PreserveCopyPage (0) true = = = = PreserveEPSInfo (0) true = = = = PreserveHalftoneInfo false = = = = PreserveOPIComments (0) false false false true true PreserveOverprintSettings false false false true true sRGBProfile (0) () = = = = StartPage (0) 1 = = = = SubsetFonts true = = = = TransferFunctionInfo (4) /Preserve = = = = UCRandBGInfo /Remove /Remove /Remove /Preserve /Preserve UseFlateCompression (2) true = = = = UsePrologue (0) false = = = =
<< /QFactor 0.9 /Blend 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>
<< /QFactor 0.4 /Blend 1 /ColorTransform 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
<< /QFactor 0.15 /Blend 1 /ColorTransform 1 /HSamples [1 1 1 1] /VSamples [1 1 1 1] >>
<< /QFactor 0.76 /Blend 1 /ColorTransform 1 /HSamples [2 1 1 2] /VSamples [2 1 1 2] >>
<</AlwaysEmbed [/Helvetica /Times-Roman]>> setdistillerparams
gs -dBATCH -dSAFER -DNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf -c '.setpdfwrite <</AlwaysEmbed [/Helvetica /Times-Roman]>> setdistillerparams' -f in.ps
ps2pdf @params.in out.pdf
-c '<</AlwaysEmbed [/Helvetica /Times-Roman]>> setdistillerparams' -f in.ps

Ghostscript PDF Printer Description

Windows xp or 2000, creating a pdf/x-3 document.

gs -dPDFX -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sDEVICE=pdfwrite -sOutputFile=out-x3.pdf PDFX_def.ps input.ps

Creating a PDF/A document

gs -dPDFA -dBATCH -dNOPAUSE -dNOOUTERSAVE -dUseCIEColor -sDEVICE=pdfwrite -sOutputFile=out-a.pdf PDFA_def.ps input.ps

Limitations

gs -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=file.pdf [more options] \   -sDEVICE=pdfwrite -c .setpdfwrite -f source1.ps [more files]
-c Postscript commands -f source1.ps [more files]

Known problems

Comparison of ps2pdf and acrobat distiller.

I haven't seen a head to head comparison, but Distiller seems slower when running on what should be a faster system (for instance, Distiller on a PPC Mac vs a 25 MHz 68040 NeXT running ps2pdf ), so I think this is fair -- also, one of Mark Doyle's postings indicated that Distiller was not fast enough for use as a run-time server. In contrast, I find that I can use ps2pdf as a post-processor during routine document creation.

Acknowledgments

IMAGES

  1. Ghostscript 9.52 Release Notice

    ghostscript pdfa outputintent

  2. Artifex Software is pleased to announce the release of Ghostscript 9.56

    ghostscript pdfa outputintent

  3. Annotation of PDF files with Ghostscript on Windows

    ghostscript pdfa outputintent

  4. Artifex Software is pleased to announce the release of Ghostscript 9.54

    ghostscript pdfa outputintent

  5. Ghostscript Xps To Pdf

    ghostscript pdfa outputintent

  6. Using Ghostscript to convert multi-page PDF into single JPG? (2

    ghostscript pdfa outputintent

VIDEO

  1. Scraping pdfdrive.com

  2. Dissertation Deposit: Converting to PDFA

  3. Tutorial: Searchable PDF file

  4. How can I split a PDF's pages down the middle?

  5. pdfRest Query PDF

  6. ChatGPT PDF Reader with HTMX UI

COMMENTS

  1. 696802

    pdf" Acrobat preflight gives error: Results (Summary) Error Device process color used but no PDF/A OutputIntent (2 matches on 1 page) No

  2. Convert PDF to PDF/A to use ghostscript

    I'd suggest you make the source and output files available, and the conformance report for those specific files. Edit. using the original file

  3. [gs-devel] PDF/A generation with ghostscript, questions

    pdf does not conform to PDF/A. Validating file "pdfa.pdf" for conformance level pdfa-1b A device-specific color space (DeviceCMYK) without an appropriate output

  4. Ghostscript Documentation

    Ghostscript is an interpreter for PostScript® and Portable Document Format (PDF) files. Ghostscript consists of a PostScript interpreter

  5. Experiments with Color Management (Ghostscript 9.27, pdf output)

    Experiments with Color Management (Ghostscript 9.27, pdf output) - GitHub - i3v/GS_ColorManagement_and_pdfOutput: Experiments with Color Management

  6. Ghostscript + QPDF and PDF/A-1b validation: how to add EOL

    Converting any PDF to PDF/A-1b with Ghostscript 9.19. gs -sDEVICE ... output intent is used. – josch. May 31, 2020 at 7:41. That command is

  7. How to create a correct (grayscale) PDF/X-3 file using Ghostscript

    It provides additional information to be included into the output document. A sample PDF/X definition file may be found in gs/lib/PDFX_def.ps .

  8. Color processing and management in Ghostscript

    This output intent can be specified either by a spe- cific ICC profile embedded in the document or a key word (e.g.. CGATS TR 001 SWOP). Version PDF/X-5n

  9. Assign AdobeRGB1998 profile with GhostScript : r/pdf

    Presumably it's PDF/A as it includes fonts. This is my call, which simply errors out: gswin64c -o "output.pdf" ^ -sICCProfilesDir=C:\Windows\

  10. The Most Complete PDL Interpreter Solution Available

    Direct PDF print. NEW. Page 4. Versions & Key Features. PDF Interpreter (Ghostscript).

  11. ps2pdf: PostScript-to-PDF converter

    ps2pdf is implemented as a very small command script (batch file) that invokes Ghostscript, selecting a special "output device" called pdfwrite. In order to use