Skip to main content
Participant
July 15, 2008
Question

Photoshop CS2: Get CMYK color from pixel?

  • July 15, 2008
  • 2 replies
  • 710 views
Hi, in Photoshop CS3 I can use colorSamplers to pick up a CMYK color from a pixel. But I haven't found anything in the CS2 scripting reference about that.

I cannot use channels["cyan"].histogram, because I need the calculated %-value (0100) from Photoshop, not the color index number (0255).

Example:
A pixel was filled with 70% cyan, Photoshop uses internally 69,8% and that's the value I want to read through a script.

Any suggestions? :-)
This topic has been closed for replies.

2 replies

Participant
July 15, 2008
OMG, that's quite obvious!
Thanks xbytor! :-)

That works:
]var cyanPercent = 100-(findPV(document.channels["Cyan"].histogram)/255*100);

]function findPV(h) {
] for (var i = 0; i <= 255; i++ ) {
] if (h) { return i; }
] }
] return 0;
]}
Known Participant
July 15, 2008
Frank_Spangenberg@adobeforums.com wrote:
> Hi, in Photoshop CS3 I can use colorSamplers to pick up a CMYK color from a pixel. But I haven't found anything in the CS2 scripting reference about that.
>
> I cannot use channels["cyan"].histogram, because I need the calculated %-value (0100) from Photoshop, not the color index number (0255).
>
> Example:
> A pixel was filled with 70% cyan, Photoshop uses internally 69,8% and that's the value I want to read through a script.
>
> Any suggestions? :-)

Try this:
var cyanPercent = (channels["cyan"].histogram/255) * 100;

-X
--
for photoshop scripting solutions of all sorts
contact: xbytor@gmail.com