• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to center 2 layer masks at selection in photoshop

Explorer ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

When i try to center two images that are smart objects with layer masks with the align buttons in photoshop it alignes it according to the whole image and not only my selection. How can i center only my selection to an other mask and not the whole images?

TOPICS
macOS , Windows

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

I'm not entirely familiar with the process, but maybe this will help.

This is the Move Tool Options bar.

That Option is accessed via the 3-dot menu.

Screen Shot 2022-05-10 at 3.34.35 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

Thak you for your reply,

I have selected that option but it doesn't seem ro be the solution.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

I see. I don't have any more ideas, but I'm sure someone knowlegable will drop by.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 10, 2022 May 10, 2022

Copy link to clipboard

Copied

To center images you need to select either 2 or more layers.... or create a selection to align to.

So if I want to align ONE item to the Center, I could select All (Command + A) and then with the move tool selected I could click the center Align icon.

If I have two buttons and I want to align them to each other... I can select a layer, and then holding down the Command key,  I can click to select any other layer. Once I have two or more layers selected, again I can select the move tool, so I can then. see. my alignment tools in the options. bar. Now when I center align, it will align the two selected layers so that they are both centerered together, but NOT centered to the page. 

 

So again, Select ALL or creating a selection will align to the Selection, and simply selecting the layers without a selection will center or align the items in the two selected. layers.


Hope that helps!

Cheers,

mark

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Hello mark, thank you for your reply

I tried what you suggested and it still aligns the whole image and not just the masked area.

Maybe my explanation of the problem isn’t clear so here is print screen.

Untitled-1.jpg

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

i want to center the contents in every square

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

In the Layers panel, click the first layer that you want to center (or align), press and hold the Command (PC: Ctrl) key, and then click any other layer that you want. Want to put them in the middle or align them to select. Also, I often align things in the document by selecting the first background layer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Untitled-2.jpg

 the proble is it selects the whole image like this

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

So when selecting a layer, it does depend on where you click. While holding the command key down, if you click on the thumbnail preview then it will create a selection based on the contents of that layer. If you click on the blank part of the layer (not the thumbnail) then it will just select the layer, which might solve your issue.

 

So you are trying to center each photo within its individual square? So the pattern and image are two different layers. It also might help to Right-Click each layer, and convert each layer with a mask to a Smart Object, then it might be easier to align and you wont have to worry about the mask moving. 

 

Try again first selecting the 2nd layer, but avoid clicking on the thumbnail and that might just solve your issue. Make sure there is no selections.

 

Cheers,

mark

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

Hmmmmm, Totally agreed with the way you described the whole process of that matter.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

thanks! I just. hope it helped the original poster!

Consulting | Design | Motion | Training>headTrix, Inc. | Adobe Certified Training & Consulting<br />Consulting | Design | Development | Training

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

To isolate if this is related to smart objects, you can duplicate the image/document and the convert two smart object layers to standard layers with masks and see if the alignment behaves differently.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

Further to my previous reply, I have just tested and yes, the alignment options are using the layer bounding area rather than the mask area to align. Here one can see that the smart objects pixel area is what has been aligned to the bottom of the canvas, not the smaller mask area of the visible content.

 

so-align.png

 

This is not related to the layer content being a smart object, it behaves the same way with standard masked layer content.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

As long as you have a mask, the image is still it tack. If you apply the mask (Layer-Layer Mask-Apply) on each layer then you can use align.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied


@edgrimley wrote:

As long as you have a mask, the image is still it tack. If you apply the mask (Layer-Layer Mask-Apply) on each layer then you can use align.


 

Yes, but one can't apply a layer mask to a smart object, one has to rasterize the smart object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

@Kssndrah 

 

Unfortunately, the entire smart object or standard layer content is used by the align command, not the visible layer bounds created by the mask.

 

The good news is that a script can use the visible, active layer bounds from the mask – and then move the active layer the required distance in order to align the layer to a given point of reference.

 

I'll have a search around for an existing script, otherwise, at least I have a new project to look into!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 15, 2022 May 15, 2022

Copy link to clipboard

Copied

I couldn't find an existing script to align using the mask vs. unmasked content, so here is a basic script to do so...

 

Select all layers to align to the canvas and then run the script.

 

It uses a CLI or "command-line interface". One must enter a two-character code for the X-axis, followed by a comma, followed by a two-character code for the Y-axis. Code entry is case insensitive and word space insensitive.

 

Example: To centre align to the canvas, one would enter:

XC,YC

 

X/Horizontal codes:

    XL = Left

    XC = Centre

    XR = Right

    NO = No change

Y/Vertical codes:

    YT = Top

    YC = Centre

    YB = Bottom

    NO = No change

    YU = Upper (optional, equates to Top)

    YL = Lower (optional, equates to Bottom)

 

I plan to add a more user-friendly, graphical ScriptUI interface, however that will take more time than I have for now. Edit: Done!

 

Additionally, I will also need to put in more work to make this work with a selection rather than the canvas.... This is proving to be harder than expected! The workaround is to ensure that the crop tool has "Delete cropped pixels" unticked, crop the image, run the script, then use Image > Reveal All to undo the non-destructive crop.

 

CLI.png

 

/* 
Align Masked Layers to Canvas Using Mask Bounds.jsx
v1.2 - 21st May 2022, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-center-2-layer-masks-at-selection-in-photoshop/td-p/12934857

v1.0 - Initial release
v1.1 - Added a validation conditional for the alignment code user entry
v1.2 - Added a NO option for no change in either X or Y alignment

Features: * Unlike the standard align feature, this script works correctly with layer masked content
          * Works with selected standard and smart object masked layers
          * Single history step undo
          * To Do - Add scriptUI
*/

#target photoshop

function main() {

    (function () {

        // Save the current ruler units and set to pixels
        var savedRuler = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        // Prompt for input
        var userInput = prompt("Enter comma separated X & Y canvas alignment positions:" + "\n" + "XL | XC | XR | NO, YT | YC | YB | NO", "NO,NO");
        if (userInput === null) {
            //alert('Script cancelled!');
        }
        var userInput = userInput.toString().toUpperCase().replace(/[^A-Z,]/g, '');

        // Validate user input
        if (/X[LCR]|NO,Y[TCBUL]|NO/.test(userInput) === true) {
            processSelectedLayers();
        } else {
            alert('Invalid command entered!');
        }

        // Restore the ruler units
        app.preferences.rulerUnits = savedRuler;


        // Functions

        function processSelectedLayers() {
            var s2t = stringIDToTypeID;
            (r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
            r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
            var lrs = executeActionGet(r).getList(p),
                sel = new ActionReference();

            for (var i = 0; i < lrs.count; i++) {
                sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
                (r = new ActionReference).putIdentifier(s2t('layer'), p);
                (d = new ActionDescriptor()).putReference(s2t("target"), r);
                executeAction(s2t('select'), d, DialogModes.NO);
                // Call the align layer function
                alignByMask();
            }
        }

        function alignByMask() {

            // Base canvas variables
            var canvasLeft = 0;
            var canvasTop = 0;
            var canvasRight = activeDocument.width.value;
            var canvasBottom = activeDocument.height.value;
            var canvasXCenter = activeDocument.width.value / 2;
            var canvasYCenter = activeDocument.height.value / 2;

            //    Bounds:
            //    + - - - - - - - [1] - - - - - - - +
            //    |                                 |
            //    |                                 |
            //   [0]                               [2]
            //    |                                 |
            //    |                                 |
            //    + - - - - - - - [3] - - - - - - - +

            // Base layer variables
            var layerLeft = activeDocument.activeLayer.bounds[0].value;
            var layerTop = activeDocument.activeLayer.bounds[1].value;
            var layerRight = activeDocument.activeLayer.bounds[2].value;
            var layerBottom = activeDocument.activeLayer.bounds[3].value;
            var layerWidth = activeDocument.activeLayer.bounds[2].value - activeDocument.activeLayer.bounds[0].value;
            var layerHeight = activeDocument.activeLayer.bounds[3].value - activeDocument.activeLayer.bounds[1].value;

            // Canvas relative X axis alignment variables
            var XL = canvasLeft - layerLeft; // X left
            var XC = canvasXCenter - layerLeft - layerWidth / 2; // X center
            var XR = canvasRight - layerRight; // X right

            // Canvas relative Y axis alignment variables
            var YT = canvasTop - layerTop; // Y top
            var YC = canvasYCenter - layerTop - layerHeight / 2; // Y center
            var YB = canvasBottom - layerBottom; // Y bottom
            var YU = YT; // Y upper = top
            var YL = YB; // Y lower = bottom

            // No change to current position
            var NO = null;

            // Align layer X, Y - using .eval() to parse the prompt string as a statement
            eval("activeDocument.activeLayer.translate(" + userInput + ")");
        }
    }());
}

activeDocument.suspendHistory("Align Masked Layers to Canvas Using Mask Bounds", "main()");

 

Saving and Installing:

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run (see below)

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2022 May 20, 2022

Copy link to clipboard

Copied

@Kssndrah â€“ Is there any feedback on my script solution?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

Hello and sorry for the delayed response thank you for taking the time to help! I tried to load the .jsx file and photoshop pops up this message.

Untitled-1.jpg

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

I don't know what you have done.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2022 May 24, 2022

Copy link to clipboard

Copied

Here is a basic version with a GUI:

 

Align-ScriptUI.png

 

/* 
Align Masked Layers to Canvas Using Mask Bounds ScriptUI.jsx
v1.0 - 24th May 2022, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-discussions/how-to-center-2-layer-masks-at-selection-in-photoshop/td-p/12934857

Features: * Unlike the standard align feature, this script works correctly with layer masked content
          * Works with selected standard and smart object masked layers
          * Single history step undo
*/

#target photoshop

/////////////////////////////// joonas scriptUI ///////////////////////////////
// ALIGNDIALOG
// ===========
var alignDialog = new Window("dialog"); 
    alignDialog.text = "Align Masked Layers to Canvas Using Mask Bounds v1.0"; // Ensure that the version number matches the header!
    alignDialog.preferredSize.width = 360; 
    alignDialog.preferredSize.height = 100; 
    alignDialog.orientation = "row"; 
    alignDialog.alignChildren = ["center","Upper"]; 
    alignDialog.spacing = 15; 
    alignDialog.margins = 20; 

// COLUMNGROUP
// ===========
var columnGroup = alignDialog.add("group", undefined, {name: "columnGroup"}); 
    columnGroup.orientation = "row"; 
    columnGroup.alignChildren = ["left","center"]; 
    columnGroup.spacing = 10; 
    columnGroup.margins = 0; 

// LEFTCOLUMN
// ==========
var leftColumn = columnGroup.add("group", undefined, {name: "leftColumn"}); 
    leftColumn.orientation = "column"; 
    leftColumn.alignChildren = ["left","center"]; 
    leftColumn.spacing = 10; 
    leftColumn.margins = 0; 

var UL = leftColumn.add("radiobutton", undefined, undefined, {name: "UL"}); 
    UL.text = "Upper Left"; 
    //UL.value = true; 

var ML = leftColumn.add("radiobutton", undefined, undefined, {name: "ML"}); 
    ML.text = "Middle Left"; 

var LL = leftColumn.add("radiobutton", undefined, undefined, {name: "LL"}); 
    LL.text = "Lower Left"; 

// CENTRECOLUMN
// ============
var centreColumn = columnGroup.add("group", undefined, {name: "centreColumn"}); 
    centreColumn.orientation = "column"; 
    centreColumn.alignChildren = ["left","center"]; 
    centreColumn.spacing = 10; 
    centreColumn.margins = 0; 

var TC = centreColumn.add("radiobutton", undefined, undefined, {name: "TC"}); 
    TC.text = "Upper Centre"; 

var MC = centreColumn.add("radiobutton", undefined, undefined, {name: "MC"}); 
    MC.text = "Middle Centre"; 

var BC = centreColumn.add("radiobutton", undefined, undefined, {name: "BC"}); 
    BC.text = "Lower Centre"; 

// RIGHTCOLUMN
// ===========
var rightColumn = columnGroup.add("group", undefined, {name: "rightColumn"}); 
    rightColumn.orientation = "column"; 
    rightColumn.alignChildren = ["left","center"]; 
    rightColumn.spacing = 10; 
    rightColumn.margins = 0; 

var TR = rightColumn.add("radiobutton", undefined, undefined, {name: "TR"}); 
    TR.text = "Upper Right"; 

var MR = rightColumn.add("radiobutton", undefined, undefined, {name: "MR"}); 
    MR.text = "Middle Right"; 

var BR = rightColumn.add("radiobutton", undefined, undefined, {name: "BR"}); 
    BR.text = "Lower Right"; 

// OKGROUP
// =======
var okGroup = alignDialog.add("group", undefined, {name: "okGroup"}); 
    okGroup.orientation = "column"; 
    okGroup.alignChildren = ["center","center"]; 
    okGroup.spacing = 10; 
    okGroup.margins = [10,0,0,0]; 

var okButton = okGroup.add("button", undefined, undefined, {name: "okButton"}); 
    okButton.text = "OK"; 
    okButton.preferredSize.width = 75; 

var cancelButton = okGroup.add("button", undefined, undefined, {name: "cancelButton"}); 
    cancelButton.text = "Cancel"; 
    cancelButton.preferredSize.width = 75; 
/////////////////////////////// joonas scriptUI ///////////////////////////////
    
////////////////////// peter kahrel scriptUI for dummies //////////////////////
// Make multiple groups act as one group
leftColumn.addEventListener("click", function () {
    for (var i = 0; i < centreColumn.children.length; i++)
        centreColumn.children[i].value = false;
});
leftColumn.addEventListener("click", function () {
    for (var i = 0; i < rightColumn.children.length; i++)
        rightColumn.children[i].value = false;
});

centreColumn.addEventListener("click", function () {
    for (var i = 0; i < leftColumn.children.length; i++)
        leftColumn.children[i].value = false;
});
centreColumn.addEventListener("click", function () {
    for (var i = 0; i < rightColumn.children.length; i++)
        rightColumn.children[i].value = false;
});

rightColumn.addEventListener("click", function () {
    for (var i = 0; i < centreColumn.children.length; i++)
        centreColumn.children[i].value = false;
});
rightColumn.addEventListener("click", function () {
    for (var i = 0; i < leftColumn.children.length; i++)
        leftColumn.children[i].value = false;
});
////////////////////// peter kahrel scriptUI for dummies //////////////////////

/////////////////////////////// joonas scriptUI ///////////////////////////////
// Execute window
alignDialog.show();
/////////////////////////////// joonas scriptUI ///////////////////////////////

function main() {

    (function () {

        // Save the current ruler units and set to pixels
        var savedRuler = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        processSelectedLayers();

        // Restore the ruler units
        app.preferences.rulerUnits = savedRuler;


        // Functions

        function processSelectedLayers() {
            var s2t = stringIDToTypeID;
            (r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
            r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
            var lrs = executeActionGet(r).getList(p),
                sel = new ActionReference();

            for (var i = 0; i < lrs.count; i++) {
                sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
                (r = new ActionReference).putIdentifier(s2t('layer'), p);
                (d = new ActionDescriptor()).putReference(s2t("target"), r);
                executeAction(s2t('select'), d, DialogModes.NO);
                // Call the align layer function
                alignByMask();
            }
        }

        function alignByMask() {

            // Base canvas variables
            var canvasLeft = 0;
            var canvasUpper = 0;
            var canvasRight = activeDocument.width.value;
            var canvasLower = activeDocument.height.value;
            var canvasXCenter = activeDocument.width.value / 2;
            var canvasYCenter = activeDocument.height.value / 2;

            //    Bounds:
            //    + - - - - - - - [1] - - - - - - - +
            //    |                                 |
            //    |                                 |
            //   [0]                               [2]
            //    |                                 |
            //    |                                 |
            //    + - - - - - - - [3] - - - - - - - +

            // Base layer variables
            var layerLeft = activeDocument.activeLayer.bounds[0].value;
            var layerUpper = activeDocument.activeLayer.bounds[1].value;
            var layerRight = activeDocument.activeLayer.bounds[2].value;
            var layerLower = activeDocument.activeLayer.bounds[3].value;
            var layerWidth = activeDocument.activeLayer.bounds[2].value - activeDocument.activeLayer.bounds[0].value;
            var layerHeight = activeDocument.activeLayer.bounds[3].value - activeDocument.activeLayer.bounds[1].value;

            // Canvas relative X axis alignment variables
            var XL = canvasLeft - layerLeft; // X left
            var XC = canvasXCenter - layerLeft - layerWidth / 2; // X center
            var XR = canvasRight - layerRight; // X right

            // Canvas relative Y axis alignment variables
            var YT = canvasUpper - layerUpper; // Y Upper
            var YC = canvasYCenter - layerUpper - layerHeight / 2; // Y center
            var YB = canvasLower - layerLower; // Y Lower
   
            // Link function parameters to radio buttons
            if (UL.value === true) {
                // Align to Upper Left
                activeDocument.activeLayer.translate(XL, YT)
            }
            if (ML.value === true) {
                // Align to Centre Left
                activeDocument.activeLayer.translate(XL, YC)
            }
            if (LL.value === true) {
                // Align to Lower Left
                activeDocument.activeLayer.translate(XL, YB)
            }
            if (TC.value === true) {
                // Align to Upper Centre
                activeDocument.activeLayer.translate(XC, YT)
            }
            if (MC.value === true) {
                // Align to Middle Centre
                activeDocument.activeLayer.translate(XC, YC)
            }
            if (BC.value === true) {
                // Align to Lower Centre
                activeDocument.activeLayer.translate(XC, YB)
            }
            if (TR.value === true) {
                // Align to Upper Right
                activeDocument.activeLayer.translate(XR, YT)
            }
            if (MR.value === true) {
                // Align to Middle Right
                activeDocument.activeLayer.translate(XR, YC)
            }
            if (BR.value === true) {
                // Align to Lower Right
                activeDocument.activeLayer.translate(XR, YB)
            }
        }
    }());
}

activeDocument.suspendHistory("Align Masked Layers to Canvas Using Mask Bounds", "main()");

 

There is no option to ignore an X or Y alignment, both horizontal and vertical positions are changed. I will have to revise the code and add 6 extra buttons to offer independent X or Y positioning... Perhaps a rainy day project!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2023 Nov 08, 2023

Copy link to clipboard

Copied

LATEST

Yes, it works. Cool

Thanks, man

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

Vote to add an option to align using mask bounds instead of layer bounds here:

 

https://community.adobe.com/t5/photoshop-ecosystem-ideas/photoshop-align-layers-using-the-masked-are...

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines