Selection bounds problem

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

Moderators: xbytor, DavideBarranca, Paul MR

Paul MR

Selection bounds problem

Postby Paul MR » Tue Jan 24, 2012 1:03 pm

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

Postby Paul MR » Tue Jan 24, 2012 1:37 pm

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

Code: Select all
getSelectionBounds = 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[i] = bnds[i].value;
    }
    return bnds;
}


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


Return to “Photoshop Scripting Bugs and Anomalies”

Who is online

Users browsing this forum: No registered users and 1 guest