• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.1K

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

LEGEND , 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('adj
...

Votes

Translate

Translate
Adobe
LEGEND ,
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[i] + ')')
	}
	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[i].push(cS[0].color.cmyk[j])
		}
		S[0].remove(), c[n = +!S.length].pop()
		str += c[n].join(', ') + ' & '
	}
	alert(str.slice(0, -7))
}

Votes

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.

Votes

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
LEGEND ,
May 13, 2018 May 13, 2018

Copy link to clipboard

Copied

So was my script useful for you?

Votes

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
Community Expert ,
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?

Votes

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)

Votes

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
LEGEND ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

LATEST

Votes

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