RSS/Atom feed Twitter
Site is read-only, email is disabled

CMYK palette info from Photoshop

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

9 of 9 messages available
Toggle history

Please log in to manage your subscriptions.

CMYK palette info from Photoshop Chris Mohler 01 Apr 02:24
  CMYK palette info from Photoshop Graeme Gill 01 Apr 03:58
  CMYK palette info from Photoshop Hal V. Engel 01 Apr 04:07
   CMYK palette info from Photoshop Chris Mohler 01 Apr 06:47
    CMYK palette info from Photoshop David Gowers 01 Apr 08:01
     CMYK palette info from Photoshop Hal V. Engel 01 Apr 18:32
      CMYK palette info from Photoshop Chris Mohler 01 Apr 19:39
    CMYK palette info from Photoshop Sven Neumann 10 Apr 17:52
     CMYK palette info from Photoshop Chris Mohler 11 Apr 01:11
Chris Mohler
2007-04-01 02:24:19 UTC (over 17 years ago)

CMYK palette info from Photoshop

Hi,

I'm working on bug #316618: http://bugzilla.gnome.org/show_bug.cgi?id=316618

I was cruising along until I found that Photoshop palettes have many CMYK data. What's the best method of converting these colors to RGB and getting reasonably close?

I tried the functions here: http://developer.gimp.org/api/2.0/libgimpcolor/libgimpcolor-GimpColorSpace.html

But they aren't working very well - is there a better method?

Thanks, Chris

Graeme Gill
2007-04-01 03:58:38 UTC (over 17 years ago)

CMYK palette info from Photoshop

Chris Mohler wrote:

I was cruising along until I found that Photoshop palettes have many CMYK data. What's the best method of converting these colors to RGB and getting reasonably close?

But they aren't working very well - is there a better method?

Using ICC profiles is the generally accepted method amongst color-savy applications.

Of course the best thing is not to convert such colors, but to leave them (tagged) in their native space until the user requires them to be converted to something else. So to fix this properly really requires that you add proper colorspace handling to Gimp, something I presume has a different bug/freature tracking number :-)

Perhaps you're best just leaving such colors out of the palette ??

Graeme Gill.

Hal V. Engel
2007-04-01 04:07:47 UTC (over 17 years ago)

CMYK palette info from Photoshop

On Saturday 31 March 2007 17:24, Chris Mohler wrote:

Hi,

I'm working on bug #316618: http://bugzilla.gnome.org/show_bug.cgi?id=316618

I was cruising along until I found that Photoshop palettes have many CMYK data. What's the best method of converting these colors to RGB and getting reasonably close?

I tried the functions here: http://developer.gimp.org/api/2.0/libgimpcolor/libgimpcolor-GimpColorSpace. html

But they aren't working very well - is there a better method?

Thanks, Chris

You might consider using a color transform using ICC profiles. For example you could use sRGB as your generic destination color space and perhaps a SWAP profile for the CMYK side. Once you have selected your two profiles doing the conversion is almost trivial using calls to lcms.

Hal

Chris Mohler
2007-04-01 06:47:30 UTC (over 17 years ago)

CMYK palette info from Photoshop

On 3/31/07, Hal V. Engel wrote:

You might consider using a color transform using ICC profiles. For example you could use sRGB as your generic destination color space and perhaps a SWAP profile for the CMYK side. Once you have selected your two profiles doing the conversion is almost trivial using calls to lcms.

Hal,

Could you point me to an example? I see some functions in plug-ins/lcms, but have not figured out how to use them. Most seem to operate on drawables - I want to push CMYK number values into RGB.

Thanks again, Chris

David Gowers
2007-04-01 08:01:51 UTC (over 17 years ago)

CMYK palette info from Photoshop

On 4/1/07, Chris Mohler wrote:

On 3/31/07, Hal V. Engel wrote:

You might consider using a color transform using ICC profiles. For

example

you could use sRGB as your generic destination color space and perhaps a

SWAP

profile for the CMYK side. Once you have selected your two profiles

doing

the conversion is almost trivial using calls to lcms.

Hal,

Could you point me to an example? I see some functions in plug-ins/lcms, but have not figured out how to use them. Most seem to operate on drawables - I want to push CMYK number values into RGB.

Chris,
The lcms plugin is a different thing from the lcms library; GIMP's lcms plugin just provides an interface to the lcms library ( http://www.littlecms.com/)
Try looking in the plugin to see how the plugin accesses LCMS, not to find out what functions the plugin provides. IIRC it basically just needs to know the input and output profiles, and be provided pointers to source and destination buffers.

Hal V. Engel
2007-04-01 18:32:51 UTC (over 17 years ago)

CMYK palette info from Photoshop

On Saturday 31 March 2007 23:01, David Gowers wrote:

On 4/1/07, Chris Mohler wrote:

On 3/31/07, Hal V. Engel wrote:

You might consider using a color transform using ICC profiles. For

example

you could use sRGB as your generic destination color space and perhaps a

SWAP

profile for the CMYK side. Once you have selected your two profiles

doing

the conversion is almost trivial using calls to lcms.

Hal,

Could you point me to an example? I see some functions in plug-ins/lcms, but have not figured out how to use them. Most seem to operate on drawables - I want to push CMYK number values into RGB.

Chris,
The lcms plugin is a different thing from the lcms library; GIMP's lcms plugin just provides an interface to the lcms library ( http://www.littlecms.com/)
Try looking in the plugin to see how the plugin accesses LCMS, not to find out what functions the plugin provides. IIRC it basically just needs to know the input and output profiles, and be provided pointers to source and destination buffers.

From my own application. This code does an RGB transform from a floating

point format image to an 8bit/channel QImage. But the same thing could be done to go from CMYK to RGB. In addition to just do one color (rather than an image) you can eliminate the nested loops and make a single call to cmsDoTransform(...) and there is likely no reason for you to be doing the normalization either:

// A ICC profile transform on whole image

void ImageItem::TransformImage(const QString OutputProfile, const QString InputProfile, vigra::DRGBImage& p, QImage& pout) {
struct dblColor
{
double r, g, b;
};

struct uint8Color
{
char r, g, b;
};

dblColor *RGB;
uint8Color *rgb;
double divisor;

RGB = (dblColor*) malloc(sizeof(dblColor)); rgb = (uint8Color*) malloc(sizeof(uint8Color));
cmsHTRANSFORM xform;
cmsHPROFILE hIn, hOut;

hIn = cmsOpenProfileFromFile(InputProfile.local8Bit(), "r"); hOut = cmsOpenProfileFromFile(OutputProfile.local8Bit(), "r");
xform = cmsCreateTransform(hIn, TYPE_RGB_DBL, hOut, TYPE_RGB_8, /*INTENT_PERCEPTUAL*/ intent, cmsFLAGS_WHITEBLACKCOMPENSATION);

vigra::DRGBImage::Iterator point=p.upperLeft();

if (uint8) divisor = 255.0; else if (int16) divisor = 65536.0; else if (int32) divisor = 4294967296.0;

for (int i=0; i < p.height(); i++) for (int j=0; j < p.width(); j++) {
if (uint8 | int16 | int32) {
// scale RGB values to max = 1.0 // since this is what is expected for // floating point images RGB->r = point(j, i).red()/divisor; RGB->g = point(j, i).green()/divisor; RGB->b = point(j, i).blue()/divisor; }
else // Floating point image // no rescaling of RGB values needed {
RGB->r = point(j, i).red(); RGB->g = point(j, i).green(); RGB->b = point(j, i).blue(); }
cmsDoTransform(xform, RGB, rgb, 1); pout.setPixel(j,i, qRgba ( rgb->r, rgb->g, rgb->b, 0xff)); }

cmsDeleteTransform(xform); cmsCloseProfile(hIn);
cmsCloseProfile(hOut);
free(RGB);
free(rgb);
}

Chris Mohler
2007-04-01 19:39:33 UTC (over 17 years ago)

CMYK palette info from Photoshop

Thanks all - I should be able to figure something out from your suggestions.

Chris

Sven Neumann
2007-04-10 17:52:18 UTC (over 17 years ago)

CMYK palette info from Photoshop

Hi,

On Sat, 2007-03-31 at 23:47 -0500, Chris Mohler wrote:

On 3/31/07, Hal V. Engel wrote:

You might consider using a color transform using ICC profiles. For example you could use sRGB as your generic destination color space and perhaps a SWAP profile for the CMYK side. Once you have selected your two profiles doing the conversion is almost trivial using calls to lcms.

Hal,

Could you point me to an example? I see some functions in plug-ins/lcms, but have not figured out how to use them. Most seem to operate on drawables - I want to push CMYK number values into RGB.

The lcms plug-in is a good example as it already uses the color profiles you need. That is the profiles configured in the Color Management section in the prefs.

The problem that we are facing here though is that the bug you are looking at is supposed to be fixed in the core. And the core doesn't know anything about color management and doesn't link against lcms. Not sure how this would best he handled. We could add functions to the lcms plug-in so that it can do the CMYK->RGB conversion for you but that would likely be too inefficient. Perhaps it's easier to write a standalone palette converter?

Sven

Chris Mohler
2007-04-11 01:11:12 UTC (over 17 years ago)

CMYK palette info from Photoshop

On 4/10/07, Sven Neumann wrote:

The lcms plug-in is a good example as it already uses the color profiles you need. That is the profiles configured in the Color Management section in the prefs.

The problem that we are facing here though is that the bug you are looking at is supposed to be fixed in the core. And the core doesn't know anything about color management and doesn't link against lcms. Not sure how this would best he handled. We could add functions to the lcms plug-in so that it can do the CMYK->RGB conversion for you but that would likely be too inefficient. Perhaps it's easier to write a standalone palette converter?

Including lcms is a bit ugly, and there's a 1000% (estimating) performance hit - but that might be something I'm doing wrong. I've also failed to get a solid conversion with lcms so far - and unless I missed it, there's no built-in CMYK profile in lcms so there's the issue of what profile we'd have to use. "Naive" conversion is fast, but obviously the colors are not accurate. I'm leaning toward just throwing out the CMYK data for now, but I'm still fiddling with it.

Chris

Sven