Skip to main content
Participant
May 14, 2021
Answered

Set white point for multiple images

  • May 14, 2021
  • 6 replies
  • 1913 views

Hi.

 

I wan't to make a Photoshop action (or possibly a script) to set the white point on mulitple images. If I record an action with Curves or Levels, 'Sample in image to set white point', it will keep using the values of the first image, used to make the action. I want it to be as if I clicked the 'Set white point' in the same position on every image upon which the action is performed. Is this possible, and if so, how?

 

Thank you very much for your help. Best wishes, Mark.

 

For info... I'm creating a time lapse, using white background photos taken with a Raspberry pi camera, which has rather variable white balance results.

 

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Kukurykus

 

function whtPnts() {
	sTT = stringIDToTypeID, arr = ['horizontal', 'vertical'];
	(ref = new ActionReference()).putClass(sTT('colorSampler'));
	(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref)
	dsc2 = new ActionDescriptor(); while(arr.length) dsc2.putUnitDouble
	(sTT(arr.shift()), sTT('pixelsUnit'), arguments[+!arr.length])
	dsc1.putObject(sTT('position'), sTT('point'), dsc2)
	executeAction(sTT('make'), dsc1)

	rgb = activeDocument.colorSamplers[0].color.rgb
	c = sTT('channel'), prprts = rgb.reflect.properties
	dsc1 = new ActionDescriptor(), lst1 = new ActionList(); for(i = 0; i < 3; i++) {
		(ref = new ActionReference()).putEnumerated(c, c, sTT(nme = prprts[i].name));
		(dsc2 = new ActionDescriptor()).putReference(c, ref); (lst2 = new ActionList())
		.putInteger(0), lst2.putInteger(rgb[nme]), dsc2.putList(sTT('input'), lst2)
		lst1.putObject(sTT('levelsAdjustment'), dsc2)
	}

	dsc1.putList(sTT('adjustment'), lst1)
	executeAction(sTT('levels'), dsc1)
}

whtPnts(250, 500)

 

Save above code to WhitePoints.jsx in Presets / Scripts of your Photoshop folder, then (re)launch Ps.

Create Action and Insert Menu Item to it from (File / Scripts) named WhitePoints.

Then use File / Automate / Batch to play your action on another files.

Ps. 250 & 500 is examplary pixels position for Color Sampler tool.

6 replies

Kukurykus
KukurykusCorrect answer
Legend
May 14, 2021

 

function whtPnts() {
	sTT = stringIDToTypeID, arr = ['horizontal', 'vertical'];
	(ref = new ActionReference()).putClass(sTT('colorSampler'));
	(dsc1 = new ActionDescriptor()).putReference(sTT('null'), ref)
	dsc2 = new ActionDescriptor(); while(arr.length) dsc2.putUnitDouble
	(sTT(arr.shift()), sTT('pixelsUnit'), arguments[+!arr.length])
	dsc1.putObject(sTT('position'), sTT('point'), dsc2)
	executeAction(sTT('make'), dsc1)

	rgb = activeDocument.colorSamplers[0].color.rgb
	c = sTT('channel'), prprts = rgb.reflect.properties
	dsc1 = new ActionDescriptor(), lst1 = new ActionList(); for(i = 0; i < 3; i++) {
		(ref = new ActionReference()).putEnumerated(c, c, sTT(nme = prprts[i].name));
		(dsc2 = new ActionDescriptor()).putReference(c, ref); (lst2 = new ActionList())
		.putInteger(0), lst2.putInteger(rgb[nme]), dsc2.putList(sTT('input'), lst2)
		lst1.putObject(sTT('levelsAdjustment'), dsc2)
	}

	dsc1.putList(sTT('adjustment'), lst1)
	executeAction(sTT('levels'), dsc1)
}

whtPnts(250, 500)

 

Save above code to WhitePoints.jsx in Presets / Scripts of your Photoshop folder, then (re)launch Ps.

Create Action and Insert Menu Item to it from (File / Scripts) named WhitePoints.

Then use File / Automate / Batch to play your action on another files.

Ps. 250 & 500 is examplary pixels position for Color Sampler tool.

AninganAuthor
Participant
May 14, 2021

Hi Kukurykus,
It worked! That's absolutely brilliant. Thank you so much.

Did you write it yourself, especially for my problem? Or is it something that's generally available? I was beginging to think I'd have to write a stand alone c++ program to do it.

What is the language of the that script? Is there a resourse from which I can learn it?

Thanks again for your help.

Kukurykus
Legend
May 14, 2021

Yes, especially for your problem, wrote in Extendscript: ADOBE PHOTOSHOP SCRIPTING

That is language made from old implementation of Javascript. Mark my answer as correct 😉