Decomposing an image to CMYK in Gimp

My stupid printer (HP Color LaserJet CP1515n) has recently started printing colour wrongly.  It seems the problem is that it’s just not using the cyan nozzle at all.  (Grr!  Printers!  Horrible things!)

On the left: Ubuntu’s printer-test page as it should appear; on the right, the same page as it appears on my printer.

To illustrate the problem, I wanted to produce the image above.

It was easy enough to get the Ubuntu printing system to spit out the left-hand side — I just poked around a bit until I found /usr/share/system-config-printer/, then viewed that in evince and screencapped the result.  But how to remove the cyan to produce the image on the right?

I was surprised that I couldn’t find a GIMP tutorial on how to do this — it seems like a useful thing to do — so I played with the program until I found a way to decompose a colour image into CMYK layers that compose as they do when printed.  Then I just made the cyan layer invisible to get the version of the test page on the right.

Since the process wasn’t trivial, I thought it might be useful if I documented it here.  No doubt there is a better way, but this is what I found.

  • Open the image in GIMP (duh)
  • From the Colours menu, pick Components -> Decompose…
  • In the popup, change Colour model to CMYK and hit OK.
  • The result is a new file, so close the original — you’re done with it.
  • The new file contains each of the four components (cyan, magenta, yellow and black) as an inverted greyscale mask, so the first thing to do is make this a colour image: Image -> Mode -> RGB.
  • Invert each of the four layers individually: Colours -> Invert.
  • Throw away the unwanted white background from each of the top three layers (cyan, magenta, yellow): Colours -> Colour to Alpha… and hit OK to accept the default colour of white.  (Keep the white background on the bottom layer).
  • Change the cyan layer to, well, cyan rather than black.  Colours -> Levels…; set Channel to Green and slide Output Levels all the way to the top; now do the same for the Blue channel and hit OK.
  • Do the same with the magenta layer, bringing the Red and Blue channels up to maximum.
  • Do the same with the yellow layer, bringing the Red and Green channels up to maximum.
  • Finally, for each of the top three layers, change the Mode (at the top of the Layers window) from Normal to Darken Only — this emulates how pigments work.

The result of all this is an image that looks exactly the same as the one you started with, but which is made of individual ink-gun layers that you can turn on and off.  All I did to produce the right-hand side of the image above was to make my cyan layer invisible.

I hope that’s helpful to someone.  (Yet I can’t shake off the nagging feeling that someone is immediately going to post a comment that says “Just use the Image -> Decompose Into Separate Overlaid CNYK Layers option.”)

Oh, and another thing …

If anyone has any idea what’s wrong with my printer, please do shout.  It’s not a problem with my computer’s driver, as it does the same thing when printing from other computers in the house, and it’s not a problem with the specific program that’s doing the printing, as we’ve seen the same thing from Firefox, OpenOffice and more.

24 responses to “Decomposing an image to CMYK in Gimp

  1. Silly question, but someone has to ask it: have you tried replacing the ink?

  2. Nice try, Joey, but it’s not going to be that easy! The cartridge is recently replaced, the printer reports it as half full, and the cyan didn’t just trail off, it simply stopped dead one day. (When toner is low, the printer just refuses to print.)

  3. Is it possible to put the toner in wrong (i.e. magenta in the cyan slot)? If so you could ‘swap them to see if the fault is in the slot or in the cartridge.

    Whatever gets the toner out of the cartridge could be bad, the drum, the drum motor, or the thing (wire?) that puts the static charge on the drum. Since it didn’t fade over time, I’d guess the drum is fine. Sounds like a motor stopped turning or the toner isn’t being pulled out of the cartridge.

    If you do the classic “shake the cartridge to redistribute the toner” thing, does that do it? Maybe it’s all stuck on the far side of the cartridge.

    As far as I know, there are no sensors in the toner cartridges to know how full they are in most lasers, it’s just estimated based on use.

  4. I would flash the firmware on the printer.

  5. Ezra Bradford

    I think this is the GIMP-intended workflow:

    Colors > Components > Decompose… (with CMYK.)
    Clear the cyan layer to black, because you don’t want any cyan.
    (e.g. set the second drawing color to black, disable the layer’s alpha channel, and Ctrl+A delete)
    Colors > Components > Compose… (with CMYK and default layer choices.)

    (There’s a Recompose, but Compose seems to work uniformly better.)

  6. Ezra Bradford

    (But of course with this technique you need to compose each time you want to change which layers are displayed, rather than simply toggling a layer display. So if it’s important to be able to toggle channels on the fly, use the originally posted method.)

  7. The Sarcastist

    So it’s broken, huh, have you tried just *fixing* it? I mean, how obvious can you get, geezgosh? :-)

  8. The GIMP can be scripted in Scheme. Scheme is an interest of yours. I suggest you write a script to automate the process in Script-Fu and email a copy to the GIMP maintainers; maybe you’ll be among the contributors when the next version comes out.

  9. Printers are notoriously known for breaking and acting up when they really shouldn’t. My guess is planned obsolescence.

  10. When/if you do get a new printer, go color laser. You’ll pay more for the printer and toner, but they last a long time and — being dry by design — don’t dry out and clog things up.

  11. Thanks to all for suggestions.

    No, mbcook, it won’t be possible to put the cartridges into the wrong slots — the design very deliberately prevents that. I fear you’re right that I am looking at a hardware failure here.

    danny, flashing the firmware is an option, but … The firmware was just fine until a week ago. Why would it suddenly have changed?

    Erza Bradford, thanks for the simpler workflow for just dumping the cyan component. I knew there had to be a way! Still, I’m glad to have figured out my way because of the separate-layers flexibility.

    Brian, writing this up as a Scheme script is a neat idea. Although I am kind of tempted to take the easy way out and use Python :-)

    Robert, your interpretation is cynical, jaded, depressing, pessimistic, and (I fear) probably right.

    Ron, that’s what’s so frustrating about this: the CP1515n is a color laser, which I bought for exactly the reasons you suggest — hoping that the bigger up-front investment would pay off in the long term, if not financially then at least in terms of saving me a lot of wasted time and frustration.

    I bought the printer on 17 December 2008, so less then three years ago. It cost £150.48 up front. Since then I’ve had to buy a replacement black toner cartridge for £55.36 and two complete sets of toner cartridges at £196.46 and £181.99. (This seems absurd to me — I am by no means a heavy user of the printer.) So it’s cost me £150.48+55.36+196.46+181.99 = £584.29 for less than three years’ printing. That’s £200 per year. I hate to say it, but the most cost-effective way of printing is probably to buy brand new low-cost inkjets, toss them out when the toner runs out and buy rolling replacements.

  12. “Color LaserJet CP1515n”
    Hmm. I’m so used to thinking of HP as selling ink jet printers, my brain just glossed over that part. Sorry.

    Anyway, my Dell 3100cn has been working pretty well for a number of years with the same consumables.

  13. Long time lurker, first time poster here. Hi!

    I’ve been involved with writing Windows drivers for a lot of HP printers, but not your particular model. I really doubt that your driver is making it do that. Since a specific toner color isn’t printing and since I believe that is a tandem laser engine (all 4 colors are imaged at the same time over a single pass of the paper), then the problem is likely:
    a) The cartridge’s security chip is refusing to let the cyan cartridge work. Does the printer show any kind of error at all, like it thinks it’s out of cyan toner or there’s an error for that cartridge If not, then;
    b) The high-voltage for that cartridge has died and toner isn’t sticking to the cyan cartridge’s imaging drum. Or;
    c) The laser for that cartridge has died and nothing is being imaged on the cyan drum.
    Usually, though, HP printers are pretty good about detecting and reporting these kinds of internal problems. The only real fix you could hope to do yourself is to install a new cyan cartridge. I know that’s an expensive experiment, though. And, for what it’s worth, I’ve rarely had problems with the laser printers, they’re usually long-lived beasts.

  14. Thank you!!!!! This was amazing.

  15. Will this work for designing something in Gimp to send to a printer that needs the image to be in CMYK color??

  16. I don’t know, sorry.

  17. Reblogged this on John Brown's Booty and commented:
    I’ve been looking all over for a way to use Gimp to turn photos into CMYK layers. There’s supposed to be this program called Separate+, but for whatever reason i can’t get it to work on my computer. So i finally found this post, and it saved the day. I’ve been playing around with it a bit, to make it more appropriate for my screenprinting needs, but all in all it’s a lifesaver.
    Before you Decompose the image, run it through the Newspaper filter: Filters -> Distorts -> Newsprint. Change the Cell Size so that it’s appropriate for your mesh count. Since this is most likely for printing onto paper, the mesh count is likely around 200, so you can probably get away with a cell size of 4 or 5. Make sure the Screen, Separate to: is set at CMYK, and bring Black pullout (%) all the way down to 0. Below are tabs that say Cyan, Magenta, Yellow and Black. The pre-programmed settings are almost fine, except that you’ll want to set Black to 45 so that they read C = 15, M = 75, Y = 0 and K = 45. And finally increase Oversample to 2. Hit Ok, and proceed to Decompose.
    After the 7th point, after you Color to Alpha, go to Colors -> Threshold, just to make sure that each layer is pure black without any grays.
    The final steps of coloring each layer is also not strictly necessary, since we’ll want to print them out in black anyway, but you might find it useful to go through the exercise to see what you can expect in the final results. It may also help you decide what order to print the colors in. The usual practice is to print lighter colors first, but that may not always ring true. Yellow, then Cyan, then Pink and Black may work for most projects, but try it out for yourself. Make sure to add a white layer in the background to give you the truest impression of how the final will turn out.

  18. Pingback: Converting an image to screenprintable CMYK layers « John Brown's Booty

  19. Pingback: Converting an image to screenprintable CMYK layers « John Brown's Booty

  20. This has been incredibly helpful! Just wanted to say thank you for taking the time to do this because I have used it so many times.

  21. This is great!
    Though dumn question, how do I export it in CMYK tif format?

    When I export it and bring to the printer he opens it in photoshop it say it’s RGB and the colours come out darker and dull.


  22. Sorry, I don’t know.

  23. I usually export to a png and then open the file in preview, then save as a PDF and print from that. Haven’t had any issues that way.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.