Skip to main content
Participant
May 14, 2021
Answered

Set white point for multiple images

  • May 14, 2021
  • 1 reply
  • 1873 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 has been closed for replies.
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.

1 reply

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.

Participant
May 16, 2022

Love this script Kukurykus! How would I modify it to sample from the right side of the image? Like 250, 250 pixels but from the top right side instead of top lef? 

Kukurykus
Legend
May 16, 2022
whtPnts(activeDocument.width - 250, 250)