Skip to main content
Participant
March 19, 2019
Question

Need a script to turn an RGB document with four greyscale layers(C, M, Y and K) into a CMYK image

  • March 19, 2019
  • 4 replies
  • 1272 views

As the title suggest, I need help scripting (which I know nothing about) a script that allows me to quickly turn a layered PSD with four (greyscale) layers, into a CMYK document using these four layers as their respective C, M, Y and K channels. Ideally if a fifth layer is present, that one should be used as a layer mask on the CMYK base layer (which, of course, isn't the background layer anymore after that).

Right now I am creating an empty CMYK document, decomposing its channels, copy/pasting my greyscale images into these, merging the channels back together, and adding the layer mask to that, which is quite a lot of work for the amount of images we have.

I'd be willing to pay for this, or an even more elaborate version of this script, which allows me to just read a given folder, checks for indentical filenames with different suffices (C, M, Y, K and Mask or something), and automatically combines them into CMYK PSD files.

Would anybody here be able to help me out? Thanks!

This topic has been closed for replies.

4 replies

Legend
March 21, 2019

Try this algorithm for you.

tmp.jsxbin - Google Drive


For verification, open 4 or 5 documents.
Each title of the documents before the last point must contain suffixes (C, M, Y or K). For a mask, the suffix is "A".
Run the script. As a result, get the document.

Stephen Marsh
Community Expert
Community Expert
March 21, 2019

Excellent work as always r-bin, that script basically automates the method that I proposed in post #9… However your script leaves the source files open and creates a new file, while my action “consumed” the open images. Sadly both of these methods remove the original base filename.

So all that is left is to script a solution that will cycle through a folder of images, taking a set of 4 or 5 images at a time with the same base filename and C|M|Y|K|A suffixes and combine the images just as your binary, then save out a file and repeat until no files were left.

If there was a source folder of say 500 images, a script would ideally output 100 combined images (presuming that all had an alpha mask).

Stephen Marsh
Community Expert
Community Expert
March 20, 2019

As a basic proof of concept, I have also tried combining the separate files using the CLI driven Image Magick tool with the following code, which worked well:

convert PROJECT-1234_C.tif PROJECT-1234_M.tif PROJECT-1234_Y.tif PROJECT-1234_K.tif  -set colorspace CMYK -negate -combine output_image.tif

I had to “cd" to the image directory, it did not like using a full path. Of course, the challenge would also be to see if one can mask and bulk process images rather than only specifying specific individual files.

ThavisJanAuthor
Participant
March 20, 2019

Wow, thanks for all these options already! To clarify, here are two screenshots about where I start, and what I would like to achieve. This would be the "easy" solution, where I still have to manually put together my C, M, Y, K and mask layers beforehand.

So basically I start with an RGB Photoshop file consisting of 5 layers. Each layer is an 8-bit greyscale image. The way these are generated is a bit more complicated, but long story short, our client wants 3D renderings of his product packaging, with a CMYK file as an output, that exactly matches the printing colors of his CMYK Illustrator designs. Since 3D renderings are always done in RGB color space, the solution was to render the C, M, Y and K components separately as greyscale images and combine them afterwards, which works perfectly. It's just a lot of work to do this manually. Here's the simplified starting point:

ITklgkP.jpg

The result should be the first four layers correctly put into the channels of a CMYK document, with the fifth layer applied as a layer mask:

TlZmzoM.jpg

The action you showed in your animated GIF and images above already takes a care of most of this, apart from the masking, but worst case would be to apply these masks manually. Could you share this action?

Also you are right, I did propose a second solution, which would need to be scripted, basically picking a directory. The script would automatically combine all the images with the same name + suffix (C, M, Y, K, MASK) into the final output like my second screenshot. This would work for batch processing, without having to put together my layers beforehand.

ThavisJanAuthor
Participant
March 20, 2019

Ah, fair enough, I managed to recreate your action. I didn't know that having properly named channels will be respected when changing the mode to CMYK, so that certainly helped! I even managed to include my mask, by just copying to the clipboard during the script, then deleting the RGB channels, converting to CMYK and then pasting the clipboard to a layer mask. One question though: What exactly does your Curves effect do in there?

Thanks a lot already!

Stephen Marsh
Community Expert
Community Expert
March 19, 2019

Here is a quick example of an action that can combine 4 layers, you can see the action steps on the left however the action playback was in accelerated mode so you can’t see the step by step process as it is too fast.

http://recordit.co/drT5xv8PG2 (video)

http://g.recordit.co/drT5xv8PG2.gif ​(animated gif version)

Stephen Marsh
Community Expert
Community Expert
March 19, 2019

Are the files originally high resolution 1-bit TIFF plate files from Workflow/RIP software?

A script would be ideal. However they can take time. An expedient approach would be a semi-automated workflow using an action, which could bulk process if you have layered files – however you may need to pre-sort the files and run separate actions for 4 or 5 layer files.

Are the files, layer names and or positions of layers consistent? Can you provide a screenshot of a 4 or 5 layer panel stack?

The second bit where you talk about batching separate files may indeed require a script if you did not wish to manually select batches of four files in Bridge as input to the workflow.

I think you need to clarify step by step what the exact situation is, show screenshots, list file or layer names etc. It sounds like you are describing both a manual process and an ideal one which may be confusing things for me.

So many things are possible, however without good information a whole lot of time and effort will be wasted.