diff --git a/selection.js b/selection.js index 151516d..3ba9e7f 100644 --- a/selection.js +++ b/selection.js @@ -50,6 +50,25 @@ async function selectionToFinalWidthHeight() { } } +async function selectBoundingBox() { + let l = await app.activeDocument.activeLayers[0] + let bounds = await l.boundsNoEffects + let selectionInfo = convertSelectionObjectToSelectionInfo(bounds) + await psapi.reSelectMarqueeExe(selectionInfo) + return selectionInfo +} +function convertSelectionObjectToSelectionInfo(selection_obj) { + let selection_info = { + left: selection_obj._left, + right: selection_obj._right, + bottom: selection_obj._bottom, + top: selection_obj._top, + height: selection_obj._bottom - selection_obj._top, + width: selection_obj._right - selection_obj._left, + } + return selection_info +} + class Selection { static getSelectionInfo() {} static isValidSelection() { @@ -63,5 +82,7 @@ class Selection { module.exports = { finalWidthHeight, selectionToFinalWidthHeight, + selectBoundingBox, + convertSelectionObjectToSelectionInfo, Selection, }