Hi,
This is the scenario:
I have two sliders that are responsible for Temperature and Tint adjustment (within Camera raw).
I also have auto white balance button.
What I want to achieve is to automatically set sliders after clicking the “Auto White Balance” button.
I’ll have to get the values of temperature and tint after Auto WB and set the values of sliders accordingly.
Do you have any idea how to do this?
This is what I do to set auto WB:
async function awb() {
const layerExistsByName = (name) => {
return Boolean(app.activeDocument?.layers?.some(layer => layer.name === name))
}
const exists = layerExistsByName("White Balance");
if (exists === false) {
await core.executeAsModal(() => {
batchPlay(
[
{
_obj: "make",
_target: [
{
_ref: "layer"
}
],
layerID: 3,
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "mergeVisible",
duplicate: true,
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "set",
_target: [
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
to: {
_obj: "layer",
name: "White Balance"
},
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "newPlacedLayer",
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "Adobe Camera Raw Filter",
$WBal: {
_enum: "$WBal",
_value: "auto"
},
_options: {
dialogOptions: "dontDisplay"
}
}
], {});
})
}
if (exists === true){
await core.executeAsModal(() => {
batchPlay(
[
{
_obj: "set",
_target: [
{
_ref: "filterFX",
_index: 1
},
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
filterFX: {
_obj: "filterFX",
filter: {
_obj: "Adobe Camera Raw Filter",
$WBal: {
_enum: "$WBal",
_value: "auto"
}
}
},
_options: {
dialogOptions: "dontDisplay"
}
}
], {});
})
}
}
document.getElementById("btnawb").addEventListener("click", awb);
This is how the sliders are set (on example of temperature):
async function tempchange() {
const layerExistsByName = (name) => {
return Boolean(app.activeDocument?.layers?.some(layer => layer.name === name))
}
const exists = layerExistsByName("White Balance");
let temp = document.querySelector("#tempSlider").value;
if (exists === false) {
await core.executeAsModal(() => {
batchPlay(
[
{
_obj: "make",
_target: [
{
_ref: "layer"
}
],
layerID: 3,
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "mergeVisible",
duplicate: true,
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "set",
_target: [
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
to: {
_obj: "layer",
name: "White Balance"
},
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "newPlacedLayer",
_options: {
dialogOptions: "dontDisplay"
}
},
{
_obj: "Adobe Camera Raw Filter",
$WBal: {
_enum: "$WBal",
_value: "customEnum"
},
$Temp: temp,
$Tint: 0,
_options: {
dialogOptions: "dontDisplay"
}
}
], {});
})
}
if (exists === true){
await core.executeAsModal(() => {
batchPlay(
[
{
_obj: "set",
_target: [
{
_ref: "filterFX",
_index: 1
},
{
_ref: "layer",
_enum: "ordinal",
_value: "targetEnum"
}
],
filterFX: {
_obj: "filterFX",
filter: {
_obj: "Adobe Camera Raw Filter",
$WBal: {
_enum: "$WBal",
_value: "customEnum"
},
$Temp: temp,
$Tint: 0
}
},
_options: {
dialogOptions: "dontDisplay"
}
}
], {});
})
}
}
document.querySelector("#tempSlider").addEventListener("change", tempchange)
I really need your help