Computing selection bounds

Photoshop Script Snippets - Note: Full Scripts go in the Photoshop Scripts Forum

Moderators: Tom, Kukurykus

xbytor

Computing selection bounds

Post by xbytor »

Cross post from the Adobe forum.

Figured this out recently. Shoulda figured it out a year ago.
It's fast and simple. It chokes if there's no active selection, but I tend to take care of that separately anyway.

Code: Select allgetSelectionBounds = function(doc) {
  var l = doc.artLayers.add();
  doc.selection.fill(app.foregroundColor);
  var bnds = l.bounds;

  doc.activeHistoryState = doc.historyStates[doc.historyStates.length-4];
  return bnds;
};

-X