Selection bounds problem

Discussion of actual or possible Photoshop Scripting Bugs, Anomalies and Documentation Errors

Moderators: Kukurykus, Tom, xbytor

Paul MR

Selection bounds problem

Post by Paul MR »

It looks as if there is a problem reporting the correct selection bounds when using the the magic wand tool.
To replicate the problem (All photoshop versions)
1) Select an area with the magic wand
2) Get the bounds ( this will be correct)
3) Select an additional area
4) Get the bounds ( this will be correct)
5) Deselect one selection, leaving one selection selected
6) Get the bounds (This will be wrong and it will be the same bounds as step 4)

So by deselecting an area the bounds of the selection are incorrect.
Is there a fix to this?

Paul MR

Selection bounds problem

Post by Paul MR »

Also by using X's function to create a new layer and get the layer bounds, this is incorrect.

Code: Select allgetSelectionBounds = function(doc) {
    if(doc == undefined) doc = activeDocument;
    var l = doc.artLayers.add();
    doc.selection.fill(app.foregroundColor);
    var bnds = l.bounds;
    var hs = doc.historyStates;
    if (hs[hs.length-2].name == "Layer Order") {
      doc.activeHistoryState = hs[hs.length-4];
    } else {
      doc.activeHistoryState = hs[hs.length-3];
    }
    for (var i = 0; i < bnds.length; i++) {
      bnds = bnds.value;
    }
    return bnds;
}

Even if the new layer is not removed, then getting the layer bounds it is incorrect.