GMIMAGEMBS in CMYK format? TIF in CMYK?

I have a number of customers who want CMYK colorspace TIF files from me.

I can see that if I start with a GMImageMBS, I can set the colorspace to 10

CMYKColorspace = 10 (Cyan, magenta, yellow, black, alpha)

but after that, it’s as if the colorspace doesn’t exist.
There are no subclasses of GMColorMBS that involve CMYK, so Im unsure how I could work with such an object.

In terms of straight Xojo, I know I can create a color using CMY(…) like I can with RGB(…)

I cant find any way to create a picture, draw in CMYK colors, and save an image (preferably TIF) with a CMYK colorspace attribute. Am I missing something?

That function doesn’t change the Picture object to be in the CMYK colorspace though. As far as I know, Xojo Pictures are always RGB.

Quickly searching through MBS, I found an importer method. You’ll have to ask @Christian_Schmitz for details on creating and exporting a CMYK image.

We have several classes related to CMYK images.

Dim pic As Picture = LogoMBS(500)
Dim g As New GMImageMBS(pic)

g.type = g.ColorSeparationType

Dim file As FolderItem = SpecialFolder.Desktop.Child("test.tif")
g.write(file)

This is very high level and may need some configuration.
Also without ICC profiles, it may not be good.
You may want to look into the LCMS examples we have and the Tiff classes.

Creating CMYK output is not as simple as drawing with a CMY colour.

Before you try to do this I recommend you ask your customers why they need CMYK files.

Jeff’s app makes printouts.

They send images to printers, printers ask for CMYK because that’s how their big machines are set up.
Either they cant be bothered to press some button that says ‘here comes an RGB image, deal with it’,
or (more likely) there is a color shift when doing the conversion which they want to avoid.
I don’t understand it all, personally.

But I’m 'that sucker who spends 3 non-chargeable weeks coding something to save 4 users from having to click twice’

(I should learn to say no)

Oh my gosh… you should avoid getting tangled up in this if you can. The printer should be competent enough to configure their output systems to properly covert trashed RGB data to the correct CMYK data specific to their output device, using an appropriate color profile.

But that means you need to tag your RGB data with an accurate color profile. sRGB would be a good starting point. It’s possible that if you are sending untagged RGB that their systems are making incorrect assumptions about it and causing output problems.

1 Like

If its a digital press then the RIP should be able to handle RGB output as long as it has been generated correctly.

  1. Do you embed a ICC Profile in the RGB files you currently generate today? If not, then this could account for the colour shift.

  2. Do you know if the colours you are generating are actually printable (its quite common for printing devices to only support a subset of colours that you can generate with RGB).

If your answer is no to the above then I would try and resolve those first to see if you can get your RGB output good enough.

If you really need to do CMYK then be prepared for a lot of work. For starters, you more than likely won’t be able to use any of the Xojo framework for drawing so you will need to find an alternative that can draw images / text / vector graphics in the CMYK colour space. You mentioned trying to use GraphicsMagick. A quick Google seems to indicate that ImageMagick / GraphicsMagick only draws in RGB but that information could be out-of-date.

An alternative might be to use DynaPDF as this would allow you to draw text and vector objects in a device specific colour space and also embed RGB images. The above rules regarding ICC Profiles / out of gamut colours would still apply though.

no to both.
dont know how, on point 1.
dont know how to test, on point 2

If you use JPEGExporterMBS or TiffPictureMBS you can attach an sRGB ICC Profile to the data.

This obviously means you need an sRGB ICC Profile. There are files available online and probably on your hard disk. An alternative could be to generate one via LCMS2ProfileMBS.CreateSRGBProfile.

Here is a very basic example of exporting a picture as a JPEG with an sRGB profile attached.

  Dim sourcePicture As Picture
  Dim iccProfileObj As LCMS2ProfileMBS
  Dim jpegExporterObj As JPEGExporterMBS
  
  iccProfileObj = LCMS2ProfileMBS.CreateSRGBProfile
  
  sourcePicture = New Picture(100, 100, 24)
  sourcePicture.Graphics.ForeColor = RGB(255, 0, 0)
  sourcePicture.Graphics.FillOval(0, 0, sourcePicture.Width, sourcePicture.Height)
  
  jpegExporterObj = New JPEGExporterMBS
  jpegExporterObj.Picture = sourcePicture
  jpegExporterObj.ProfileData = iccProfileObj.SaveProfileToString
  jpegExporterObj.File = SpecialFolder.Desktop.Child("TestWithProfile.jpg")
  jpegExporterObj.Export

If you open the image in a graphics package it should state that it has an ICC Profile attached.

Note that he said “multiple customers” which suggests “multiple printers” which further implies “multiple output devices” and “multiple color profiles”. Tagging his RGB files with a color profile is the best approach here.

What’s the content being drawn, by the way? Photographs? Graphs? Lines and text?

I imagine you would have to speak to your customers to see which colours are still affected after they have printed some of your ICC Profile tagged files. Please be aware that this could be different for each customer as printing equipment, ink and paper all impact this.

If you want to see the impact on RGB colours when converted to CMYK you can experiment with the calculator option in the macOS ColorSync utility. This allows you to choose a RGB profile, a RGB colour, a CMYK profile and see how the colour is affected. NOTE. I did notice a bug in the utility where changing the CMYK profile didn’t update the result until the RGB colour values were changed.

Solid colors, text, lines… think Powerpoint stuff, but with a need to represent a real-world color match.
Which is of course ludicrous when you cross the screen to print threshold, as the color management is totally different.

If the image contains color profile in it then Color profile plugin either from Christian or me for example would convert it to your screen profile, or sRGB if that was fitting or wanted.

Yeesh. What a pain.

Will they accept a PDF? You might have better results if you send them tagged vector data. Although I don’t have much confidence that Xojo’s built-in PDF support will be up to the task.

What’s your source for the colors that need to be matched? RGB values? Pantone color spec? Something else?

also.
If you generate a PDF with vector objects / text, the output will be much better quality than a raster file.

Adding a color profile to the RGB picture should be fine.
The printing software then can do proper CMYK conversion.

Or use DynaPDF plugin to make a PDF, which can contain RGB and CMYK content.

I don’t recommend this. Some prepress systems will flag mixed-mode PDFs as problematic, even if everything is properly tagged.

If you generate a PDF with vector objects / text,

Yeah. Not an option.
But I need to say- this isn’t a commission job.
This is to cater for a few customers of an ‘off-the-shelf’ tool, who feel that this is a ‘feature request’
I don’t want to actually spend weeks doing something which doesn’t provide a benefit for the majority of users, and the people who want this aren’t wanting to pay actual money for customisation.
So my first port of call is to work out how to get a profile into that TIF file.

At the moment, I’m saving as TIF from GMImageMBS
But I can look into switching to TIFFPictureMBS which I do use in another part of my app

ImageMagick could do this for you as well from the command line. If I were you, I would send these customers a file where you’ve manually assigned the profile with some tool to make sure it meets their needs before investing in any code changes.