3

I have a large batch of PDFs (6,000 +) that need to be converted from a CMYK color profile to RGB. Are there any scripts that can accomplish this task, and ideally without a (too) visible change in color? The PDFs are book files that were originally designed for print and are being prepared to be loaded as e-books.

I've found a few InDesign scripts that might be able to do this, but at this point obtaining and re-exporting from the original design files will be extraordinarily time consuming. Another option seems to be running actions via Adobe Acrobat, but I haven't had any success with that yet.

I've also found this bit of Java, if anyone can vouch for it: http://www.aspose.com/docs/display/pdfjava/Changing+Color+space+of+a+PDF+document

Any suggestions or insights?

halfer
  • 19,824
  • 17
  • 99
  • 186
ke_w15c
  • 31
  • 1
  • 2

3 Answers3

5

You can use Ghostscript for this job. Make sure to use a very recent release though.

Here is a command to try:

 gs                                      \
  -o rgb.pdf                             \
  -sDEVICE=pdfwrite                      \
  -sProcessColorModel=DeviceRGB          \
  -sColorConversionStrategy=RGB          \
  -sColorConversionStrategyForImages=RGB \
   cmyk.pdf

Note, that your goal to achieve the conversion 'ideally without a (too) visible change in color' is not always possible. It very much depends on wether the input PDF did use an embedded color profile, and which.

It also depends on the color profile you apply. Above command will use a default RGB profile compiled into Ghostscript. To use a custom profile, you can add various command line parameters. To use one profile for all types of PDF content, use:

 -sDefaultRGBProfile=rgb-profile-filename

This defines source colors which are not already colorimetrically defined in the source docu- ment.

If you want to override the profiles which are already embedded in the PDF document, add this:

 -dOverrideICC=true

On top of these options, you can also control the ICC profile for the output device, by adding:

 -sOutputICCProfile=output-profile-filename

When using an output profile, you frequently also want to set the rendering intent. For this purpose use:

 -dRenderIntent=intent

where intent is one of

  • 0 : for Perceptual
  • 1 : for Colorimetric
  • 2 : for Saturation
  • 3 : for Absolute Colorimetric intent.

Ghostscript even supports to use different profiles for different types of PDF content: graphics, text and images. See here:

 -sGraphicICCProfile=graphicprofile-filename
 -sTextICCProfile=textprofile-filename
 -sImageICCProfile=imageprofile-filename

Similar to the above explained generic option -dRenderIntent, you can specify different intents for different content types:

 -dGraphicIntent=intent
 -dTextIntent=intent
 -dImageIntent=intent
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • Works perfectly. – Dan Gayle Apr 07 '17 at 23:11
  • Devs say ([1](https://bugs.ghostscript.com/show_bug.cgi?id=700819#c1),[2](https://bugs.ghostscript.com/show_bug.cgi?id=693716#c4),[3](https://ghostscript.com/irclogs/2012/11/21.html),[4](https://stackoverflow.com/a/36337225/1032586)) that there's no `-sColorConversionStrategyForImages` switch. – Igor Mar 19 '19 at 22:12
0

I'd use Adobe Acrobat Pro. Go into Tools, Preflight (might be in a different spot depending on what version you have).

enter image description here

In the PDF fixups section look for "Convert to sRGB". You can run this command manually a single PDF to see if it works for you. If it does, go to the Options menu and select "Create Preflight Droplet"

enter image description here

You'll get some options about what to do on success and failure but when you click the "Save" button you'll get an actual EXE file for Windows, Mac you should get an Application file. This file you can drag file and I think folders directly only to and it will run that action, just like Photoshop.

enter image description here

Chris Haas
  • 53,986
  • 12
  • 141
  • 274
0

Preflight generated using Adobe Acrobat Pro can be used in a batch process. In my case I have to convert spot colors to CMYK without affecting other colours so i choose convert to CMYK only (SWOP) in the PDF fixups section

A .exe file is generated after saving the preflight. That can be tested using the command below in command prompt this can be tested.

"%location_of_file%\Convert to CMYK only (SWOP).exe" "" "%file_name%"

I also prepared a script so as to automate the process i can give the small prototype of it.

d:
cd %dir% ::directory on which the batch process is to be run.
:cycle
set count_files=0
for %%x in (*.pdf) do set /a count_files+=1 ::PDF in my case so *.pdf
if %count_files%==0 ( GOTO :MISSING ) else (for /F %%a in ('dir /a-d /b /o-d *.pdf') do set oldest=%%a)
"%location_of_executable%\Convert to CMYK only (SWOP).exe" "" "%oldest%"
move %oldest%  %output_folder_with_location%\%oldest%
timeout 3 ::delay so that conversion process get completed
:MISSING
goto :cycle

This batch script goes on looping itself weather it gets failed or pass and in case there are PDF to be processed this BATCH script starts converting the oldest file first.