Copy link to clipboard
Copied
I noticed some pixel masks change when the canvas size is increased.
An example, if you have a 100% black mask, some masks stay filled black when the canvas increases, or the mask is moved. But some mask seem to have a white background, making the increased canvas size appear white in the mask, or when dragged, the surrounding becomes white.
I noticed how this difference is created. When you create a new mask, it's white, you can invert the mask, and it becomes black, and stays black. But if you take the new mask, select all, and fill it black, than it doesn't stay black when adjusted. So while these masks appear the same, they act differently.
Is there a way to detect if it's an "empty" mask, white or black. Or if a mask is just filled white or black?
Maybe some action manager code can identify some parameter that shows this difference in mask type?
I could make a script that moves the mask, and then reads back the histogram to detect a change, but I'm hoping there is a more elegant solution. I didn't even know about this mask type difference untill today.
My goal is to create a script that makes sure all masks that are 100% white of black are truly "infinite" masks that stay the same after a canvas size change.
Copy link to clipboard
Copied
Can you post a layered PSD that clearly demonstrates the issues?
Copy link to clipboard
Copied
del.
p.s. Wrong way
Copy link to clipboard
Copied
Copy link to clipboard
Copied
You can recreate a mask from the current one with a guaranteed black color outside.
// selection from mask
var d = new ActionDescriptor();
var r = new ActionReference();
r.putProperty(stringIDToTypeID("channel"), stringIDToTypeID("selection"));
d.putReference(stringIDToTypeID("null"), r);
var r1 = new ActionReference();
r1.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
d.putReference(stringIDToTypeID("to"), r1);
executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
// delete mask
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
d.putReference(stringIDToTypeID("null"), r);
executeAction(stringIDToTypeID("delete"), d, DialogModes.NO);
try { // mask from selection
var d = new ActionDescriptor();
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
d.putReference(stringIDToTypeID("at"), r);
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskOptions"), stringIDToTypeID("revealSelection"));
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) // no selection, black mask
{
try {
var d = new ActionDescriptor();
d.putClass(stringIDToTypeID("new"), stringIDToTypeID("channel"));
var r = new ActionReference();
r.putEnumerated(stringIDToTypeID("channel"), stringIDToTypeID("channel"), stringIDToTypeID("mask"));
d.putReference(stringIDToTypeID("at"), r);
d.putEnumerated(stringIDToTypeID("using"), stringIDToTypeID("userMaskOptions"), stringIDToTypeID("hideAll"));
executeAction(stringIDToTypeID("make"), d, DialogModes.NO);
}
catch (e) { alert(e); }
}
UPD.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now