Grd2cpt - unable to output values in CMYK

I am trying to make a series of bathymetry plots for a marine geology textbook. I created a custom cpt that is broadly similar to the standard rainbow palette to use as my master cpt, and then I want to use grd2cpt to make a new cpt for each plot with customized depth ranges/increments. I am able to do that successfully, but I think I may have found a bug related to using CMYK colors.

Since the figures are for a textbook, the publisher wants the images in CMYK. I created and tested the master cpt, then used it to create a new cpt for one of my plots, but I noticed that no matter what I do, the values in the new cpt file are RGB, not CMYK. Here’s an example line in case it helps (GMT6, classic mode):

gmt grd2cpt Fig5_9A_MAR.grd -Cocean-cmyk.cpt -Z -E -L-7000/-1000 -Fc > Fig5_9A_MAR.cpt

I have triple-checked that PS_COLOR_MODE is cmyk in the gmt.conf file in the working directory, and I even used the -Fc option to force it to output CMYK values, but the values still come out as RGB triples. On top of that, the background (“B”) and foreground (“F”) values are not even close to what they should be if they were translated from the master cpt file (e.g., the B value in the master cpt is 70/63/62/59, which is a dark gray, and it was translated to 0/0/0 in the new cpt, which of course is black).

I attached the two cpt files, but note that I had to switch the file extension to .txt since it wouldn’t let me upload a .cpt file (may be another thing to fix when you have a chance?).

Fig5_9A_MAR.txt (959 Bytes)
ocean-cmyk.txt (652 Bytes)

I am looking at this and there is at least 1 type of bug here.

The key problem was the output of CMYK missed the conversion from 0-1 to percentages. I have submitted a pull request that fixes this problem - hopefully it will be approved and merged soon.

However, I have some additional comments:

  1. You should be aware of the problems with using a rainbow color table; see this page for the full story. If you insist on a rainbow we recommend turbo.
  2. Note that GMT will internally convert CMYK to RGB and then back to CMYK again. This round-trip is occasionally non-unique and the output CMYK differs from the input, even though the colors might be the same. See the comments on the pull request.
  3. I am always suspicious of publishers requesting CMYK since without specific information about printers there is no information difference between a RGB and CMYK image. So wasting everybody’s time.

This link has some useful information about RGB and CMYK.

PR has now been merged into master

Thanks Paul! I appreciate the fast response and fix. I will discuss the colormap issue with the textbook authors (I was hired strictly as a graphics person for one of the two authors). I agree with you about CMYK vs. RGB, but the publisher is Cambridge University Press, so I imagine they are pretty set in their ways.