Very interesting. And to answer your question, the layer selections will be automated as well. The only thing that will be done manually is any touch-up that's necessary to finalize the look of the output. This would include, but not be limited to, cleaning up unintentional color patterns, offsetting the image to make it tileable (though I might look at possibly automating this as well), and/or adding foreground/background objects.
I also played around with your histogram idea a bit (never really used it before) and came up with the following code that, while not perfect, does work in some cases; and in 0.01s, no less:
function overlapCheck() {
myDoc.activeLayer.visible = false;
selectOpac();
//myDoc.activeLayer = myDoc.layers.getByName("Layer 0");
var overlap = false;
var histo = app.activeDocument.histogram;
for(var i in histo) {
if(histo[i] > 0 && histo[i] < 255) {
overlap = true;
break;
}
}
return overlap;
}
function selectOpac() {
var idsetd = charIDToTypeID( "setd" );
var desc4 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idfsel = charIDToTypeID( "fsel" );
ref2.putProperty( idChnl, idfsel );
desc4.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var ref3 = new ActionReference();
var idChnl = charIDToTypeID( "Chnl" );
var idChnl = charIDToTypeID( "Chnl" );
var idTrsp = charIDToTypeID( "Trsp" );
ref3.putEnumerated( idChnl, idChnl, idTrsp );
desc4.putReference( idT, ref3 );
executeAction( idsetd, desc4, DialogModes.NO );
}
This will consistently return whether there is an overlap or not as long as one of 2 requirements are met:
- The document must have a white or transparent background
- This also has a sub-requirement that you cannot be attempting to check for overlap with one object while ignoring overlap with another.
or:
- The histogram must have its source set to "Selected Layer"
- This one requires that no more than 1 layer be selected at any one time during the script or it reverts to "entire document" mode, at which point the above requirement comes into play.
- This also requires that the commented line in the code above be uncommented and the appropriate layer be set as active (Layer 0 was used for my test).
Unfortunately, these flaws make it nearly useless in most cases. If there were a way to set the histogram's "source" through scripting, the second issue could be averted and this would likely be the fastest way to check. From what I've seen, though, it's not possible to change that via scripting, and the amount of time saved would be minimal compared to what's already being saved.
Regardless, both yours and EnsilZah's methods are a vast improvement over the manual method, so I thank you both for your assistance!