How can I convert from PDF to JPG without colours changing?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
MorgZ

How can I convert from PDF to JPG without colours changing?

Post by MorgZ »

I am trying to convert PDFs to images but when I run the command the colours seem to change in the resulting image. The most obvious is that a dark blue colour #0040CS (R0 G64 B197) gets mapped to #004B8E (R0 G75 B142) - using Firefox colour picker tool on the resulting image.

The command I am using is:

"convert test.pdf -resize 340x500 test.jpg"

I have tested this with/without the resize and changing the output file type (jpg / gif / tif). I have also seen if I can reduce the brightness to negate some of the difference in colour. If it helps it looks like the resulting image might be a little bit saturated (just to my eye).

I have had a good search through the forum and on Google and have read that it might be todo with some of the following:

- colorspace
- ghostscript colour translations (I read there is a parameter which can be added to delegates.xml "-dUseCIEColor")

If anyone could give me any guidance here it would be much appreciated as I am not really too sure how I can rectify this issue.

Thanks in advance.

Dave
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How can I convert from PDF to JPG without colours changing?

Post by fmw42 »

is your pdf using cmyk?

what do you get from

identify -verbose imagename


you may need to use profiles to get good color conversion
MorgZ

Re: How can I convert from PDF to JPG without colours changing?

Post by MorgZ »

Thanks for the quick reply!

I am fairly certain the PDFs are CMYK.

Using the identify -verbose imagename command I get the following:

Code: Select all

Image: b90c6b87c1ad464c54f18efc3164ee9f2bc072de.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Geometry: 340x240
  Class: DirectClass
  Type: ColorSeparation
  Endianess: Undefined
  Colorspace: CMYK
  Channel depth:
    Cyan: 8-bits
    Magenta: 8-bits
    Yellow: 8-bits
    Black: 8-bits
  Channel statistics:
    Cyan:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 219.688 (0.86152)
      Standard deviation: 40.8306 (0.16012)
    Magenta:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 215.184 (0.843859)
      Standard deviation: 38.7639 (0.152015)
    Yellow:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 165.958 (0.650815)
      Standard deviation: 65.3878 (0.256423)
    Black:
      Min: 0 (0)
      Max: 255 (1)
      Mean: 203.226 (0.796964)
      Standard deviation: 73.4102 (0.287883)
  Total Ink Density: 400%
  Colors: 31794
  Rendering-intent: Undefined
  Resolution: 28x28
  Units: PixelsPerInch
  Filesize: 158kb
  Interlace: None
  Background Color: white
  Border Color: #DFDFDF
  Matte Color: grey74
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 100
  Orientation: Undefined
  JPEG-Colorspace: 4
  JPEG-Sampling-factors: 1x1,1x1,1x1,1x1
  Signature: bc5401da0f7eb113926f9ae30a0cc9ffc11d35de8175195bdc8e07f044108a05
  Tainted: False
  User Time: 0.010u
  Elapsed Time: 0:02
  Pixels per second: 80kb
  Version: ImageMagick 6.2.5 02/13/06 Q16 file:/usr/share/ImageMagick-6.2.5/doc/index.html
I have done further searching and found a few mentions of LCMS which apparently helps matching colours?

Doing a ./configure command shows:

Code: Select all

LCMS              --with-lcms=yes               no
Do I need to change that "no" to "yes" and if so how would I go about that? I have checked with yum and it seems "lcms" is installed on my machine.

I have also had a read up on color profiles but I have no idea how you actually create or get hold of one, only how you can use them with ImageMagick once you have them.

Any further help much appreciated.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How can I convert from PDF to JPG without colours changing?

Post by fmw42 »

try

convert -colorspace RGB image.pdf image.jpg
Post Reply