Applescript/Photoshop and reading sampled colour values, or possibly a Javascript solution

New Here ,
Jan 25, 2018 Jan 25, 2018

Copy link to clipboard

Copied

Hi all,

I've used Image->Adjustments->Thresholds to sample the darkest and lightest points of an image with the eyedropper tool. This provides me with two, in this case, CMYK measurements in the Info pane. What I'm trying to establish are the AppleScript commands to retrieve these CMYK values from either the points being sampled or those registering in the Info pane. As pointed out to me by c.pfaffenbichler, the solution may be provided via Javascript. As I don't really know this language, I'd prefer an Applescript solution, but I'll work with Javascript if needs must.

I have searched the interweb and haven't returned any useful information, although I concede that I may I've used incorrect search terms. I've also looked through the Applescript dictionaries too.

I'd be really grateful for any assistance.

Ian Thompson

TOPICS
Actions and scripting

Views

783

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Jan 25, 2018 Jan 25, 2018
Choose layer you want to set Threshold for, then run script. It's going to create new (theshold) adjustment for that layer and make back your layer an active one. Then it stops that you can use 'Color Sampler Tool' on layer. When you do it, run script again, so it will check CMYK values for chosen positions to alert them at end.if ((l0 = (aD = activeDocument).layers[0]).kind != LayerKind.THRESHOLD) {     function sTT(v) {return stringIDToTypeID(v)}     (ref1 = new ActionReference()).putClass(sTT...

Likes

Translate

Translate
Adobe Community Professional ,
Jan 25, 2018 Jan 25, 2018

Copy link to clipboard

Copied

Choose layer you want to set Threshold for, then run script. It's going to create new (theshold) adjustment for that layer and make back your layer an active one. Then it stops that you can use 'Color Sampler Tool' on layer. When you do it, run script again, so it will check CMYK values for chosen positions to alert them at end.

if ((l0 = (aD = activeDocument).layers[0]).kind != LayerKind.THRESHOLD) {

     function sTT(v) {return stringIDToTypeID(v)}

     (ref1 = new ActionReference()).putClass(sTT('adjustmentLayer'));

     a = ["Reference(sTT('null'), ref1", "Integer(sTT('level'), 128",

          "Object(sTT('type'), sTT('thresholdClassEvent'), dsc2"]

     for(i = 0; i < a.length; i++) {

          eval("(dsc" + (i + 1) + " = new ActionDescriptor()).put" + a + ')')

     }

     dsc1.putObject(sTT('using'), sTT('adjustmentLayer'), dsc3)

     executeAction(sTT('make'), dsc1, DialogModes.NO)

}

else if(str = '', l0.remove(), (cS = Array()

.slice.call(S = aD.colorSamplers)).length) {

     for (c = [[], []], i = 0; i < cS.length; i++) {

          for(j in cS[0].color.cmyk) {

               c.push(cS[0].color.cmyk)

          }

          S[0].remove(), c[n = +!S.length].pop()

          str += c.join(', ') + '   &   '

     }

     alert(str.slice(0, -7))

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 29, 2018 Jan 29, 2018

Copy link to clipboard

Copied

Thank you Kukuryks. I'll have a look at this later today.

I greatly appreciate you posting a solution, Cheers.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 13, 2018 May 13, 2018

Copy link to clipboard

Copied

So was my script useful for you?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jan 25, 2018 Jan 25, 2018

Copy link to clipboard

Copied

Do you wish to “capture” the color sampler values and store them in a variable and or use the sampled values in some other way?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

How might I do this?

(Sorry reviving and old thread)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines