Skip to main content
Inspiring
May 10, 2022
Question

How to center 2 layer masks at selection in photoshop

  • May 10, 2022
  • 11 replies
  • 5124 views

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?

11 replies

Stephen Marsh
Community Expert
Community Expert
April 7, 2025

This 1.2 version should work correctly to align masked layer groups to the canvas.

/* 
Align Masked Layers to Canvas Using Mask Bounds ScriptUI v1-2.jsx
Stephen Marsh
v1.0 - 24th May 2022:  Initial release using a Radio Button UI
v1.1 - 7th April 2025: Revised to use Dropdown Menus
v1.2 - 7th April 2025: Revised to process layer groups (requires Photoshop 21.0)
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, smart object or layer groups containing layer masks
          * Single history step undo
*/

#target photoshop;

// Ensure that version 2021 or later is being used
var versionNumber = app.version.split(".");
var versionCheck = parseInt(versionNumber);
if (versionCheck < 22) {
    alert("You must use Photoshop 2021 or later to run this v1.2 script!");
} else {
    function main() {
        (function () {
            var savedRuler = app.preferences.rulerUnits;
            app.preferences.rulerUnits = Units.PIXELS;

            var userInput = showDialog();
            if (userInput === null) {
                app.preferences.rulerUnits = savedRuler;
                return;
            }

            if (/^(No Change|Left|Center|Right),(No Change|Top|Center|Bottom)$/.test(userInput)) {
                // Align the selected layers
                processSelectedLayers(userInput);
            }

            app.preferences.rulerUnits = savedRuler;

            function showDialog() {
                // Create the dialog window
                var dlg = new Window("dialog", "Align Masked Layers to Canvas (v1.2)");
                dlg.orientation = "column";
                dlg.alignChildren = "left";
                dlg.preferredSize.width = 300;

                // Add the panel for the dropdowns
                var dropdownGroup = dlg.add("panel", undefined, "Alignment Options");
                dropdownGroup.orientation = "column";
                dropdownGroup.alignChildren = "fill";
                dropdownGroup.margins = [10, 15, 10, 10];
                dropdownGroup.alignment = "fill";

                dropdownGroup.add("statictext", undefined, "X Alignment:");
                var xDropdown = dropdownGroup.add("dropdownlist", undefined, ["No Change", "Left", "Center", "Right"]);
                xDropdown.selection = 0;

                dropdownGroup.add("statictext", undefined, "Y Alignment:");
                var yDropdown = dropdownGroup.add("dropdownlist", undefined, ["No Change", "Top", "Center", "Bottom"]);
                yDropdown.selection = 0;

                var btnGroup = dlg.add("group");
                btnGroup.orientation = "row";
                btnGroup.alignment = "right";
                var cancel = btnGroup.add("button", undefined, "Cancel");
                var ok = btnGroup.add("button", undefined, "OK", { name: "ok" });
                ok.preferredSize.width = 80;
                cancel.preferredSize.width = 80;

                // Button event handlers
                var result = null;
                ok.onClick = function () {
                    result = xDropdown.selection.text + "," + yDropdown.selection.text;
                    dlg.close();
                };
                cancel.onClick = function () {
                    result = null;
                    dlg.close();
                };

                dlg.show();
                return result;
            }

            function processSelectedLayers(alignmentString) {
                var s2t = stringIDToTypeID;
                // Get the IDs of the currently selected layers
                var ref = new ActionReference();
                ref.putProperty(s2t("property"), s2t("targetLayersIDs"));
                ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"));
                var layerList = executeActionGet(ref).getList(s2t("targetLayersIDs"));
                var selectedIDs = [];
                for (var i = 0; i < layerList.count; i++) {
                    selectedIDs.push(layerList.getReference(i).getIdentifier(s2t("layerID")));
                }

                var tempSmartObjects = []; // Store [originalLayerID, newSmartObjectID]
                var finalLayerIDs = selectedIDs.slice(); // Ensure this is an array copy

                // Select the layers and align them
                for (var j = 0; j < selectedIDs.length; j++) {
                    selectLayerByID(selectedIDs[j]);
                    if (isLayerGroup()) {
                        executeAction(s2t("newPlacedLayer"), undefined, DialogModes.NO);
                        var newID = getActiveLayerID();
                        tempSmartObjects.push([selectedIDs[j], newID]);
                    }
                    alignByMask(alignmentString);
                }

                // Convert temporary smart objects back to layers and update final IDs
                // Requires Photoshop 21.0 or later
                for (var i = 0; i < tempSmartObjects.length; i++) {
                    selectLayerByID(tempSmartObjects[i][1]);
                    executeAction(s2t("placedLayerConvertToLayers"), undefined, DialogModes.NO);
                    var newLayerID = getActiveLayerID();
                    // Safely update finalLayerIDs
                    var originalID = tempSmartObjects[i][0];
                    var originalIndex = -1;
                    for (var k = 0; k < finalLayerIDs.length; k++) {
                        if (finalLayerIDs[k] === originalID) {
                            originalIndex = k;
                            break;
                        }
                    }
                    if (originalIndex !== -1) {
                        finalLayerIDs[originalIndex] = newLayerID;
                    } else {
                        // If not found, append the new ID (shouldn't happen, but as a fallback)
                        finalLayerIDs.push(newLayerID);
                    }
                }

                // Re-select the original layers
                if (finalLayerIDs.length > 0) {
                    // Deselect all layers first
                    var deselectDesc = new ActionDescriptor();
                    var deselectRef = new ActionReference();
                    deselectRef.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("allEnum"));
                    deselectDesc.putReference(s2t("target"), deselectRef);
                    executeAction(s2t("selectNoLayers"), deselectDesc, DialogModes.NO);
                    // Select all layers in finalLayerIDs
                    for (var k = 0; k < finalLayerIDs.length; k++) {
                        var selDesc = new ActionDescriptor();
                        var selRef = new ActionReference();
                        selRef.putIdentifier(s2t("layer"), finalLayerIDs[k]);
                        selDesc.putReference(s2t("target"), selRef);
                        if (k > 0) {
                            selDesc.putEnumerated(s2t("selectionModifier"), s2t("selectionModifierType"), s2t("addToSelection"));
                        }
                        selDesc.putBoolean(s2t("makeVisible"), false);
                        executeAction(s2t("select"), selDesc, DialogModes.NO);
                    }
                }
            }

            function isLayerGroup() {
                var ref = new ActionReference();
                ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerSection"));
                ref.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
                var desc = executeActionGet(ref);
                var type = desc.getEnumerationValue(stringIDToTypeID("layerSection"));
                var typeString = typeIDToStringID(type);
                return typeString === "layerSectionStart";
            }

            function getActiveLayerID() {
                var ref = new ActionReference();
                ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("layerID"));
                ref.putEnumerated(stringIDToTypeID("layer"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
                return executeActionGet(ref).getInteger(stringIDToTypeID("layerID"));
            }

            function selectLayerByID(ID) {
                var ref = new ActionReference();
                ref.putIdentifier(stringIDToTypeID("layer"), ID);
                var desc = new ActionDescriptor();
                desc.putReference(stringIDToTypeID("target"), ref);
                desc.putBoolean(stringIDToTypeID("makeVisible"), false);
                executeAction(stringIDToTypeID("select"), desc, DialogModes.NO);
            }

            function alignByMask(userInput) {
                var parts = userInput.split(",");
                var xAlign = parts[0];
                var yAlign = parts[1];

                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;

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

                var dx = 0;
                var dy = 0;

                switch (xAlign) {
                    case "Left": dx = canvasLeft - layerLeft; break;
                    case "Center": dx = canvasXCenter - layerLeft - layerWidth / 2; break;
                    case "Right": dx = canvasRight - layerRight; break;
                }

                switch (yAlign) {
                    case "Top": dy = canvasTop - layerTop; break;
                    case "Center": dy = canvasYCenter - layerTop - layerHeight / 2; break;
                    case "Bottom": dy = canvasBottom - layerBottom; break;
                }

                activeDocument.activeLayer.translate(dx, dy);
            }
        })();
    }
}
activeDocument.suspendHistory("Align Masked Layers to Canvas", "main()");

 

  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 as a plain text format file – .txt
  5. Rename the saved 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

Known Participant
April 7, 2025

Works like a charm. Thanks for revisiting this @Stephen Marsh !

Best.

Matt

Stephen Marsh
Community Expert
Community Expert
April 7, 2025

@Little_Matty - You're welcome! I cheated using temporary smart objects. Time permitting I'll look into using the bounds of the mask.

Stephen Marsh
Community Expert
Community Expert
May 25, 2022

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-areas/idc-p/12964582

 

Stephen Marsh
Community Expert
Community Expert
May 24, 2022

EDIT: The Original v1.0 script from 2022 has now been updated with a new GUI and improved functionality!

/* 
Align Masked Layers to Canvas Using Mask Bounds ScriptUI v1-1.jsx
v1.0 - 24th May 2022, Stephen Marsh: Basic Radio Button UI
v1.1 - 7th April 2025, Stephen Marsh: Revised to use Dropdown Menus
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 (not intended for layer groups)
          * Single history step undo
*/

#target photoshop
function main() {
    (function () {

        var savedRuler = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var userInput = showDialog();
        if (userInput === null) {
            app.preferences.rulerUnits = savedRuler;
            return;
        }
        if (/^(No Change|Left|Center|Right),(No Change|Top|Center|Bottom)$/.test(userInput)) {
            // Align the selected layers
            processSelectedLayers(userInput);
        }

        app.preferences.rulerUnits = savedRuler;

        function showDialog() {
            // Create the dialog window
            var dlg = new Window("dialog", "Align Masked Layers to Canvas (v1.1)");
            dlg.orientation = "column";
            dlg.alignChildren = "left";
            dlg.preferredSize.width = 300;

            // Add the panel for the dropdowns
            var dropdownGroup = dlg.add("panel", undefined, "Alignment Options");
            dropdownGroup.orientation = "column";
            dropdownGroup.alignChildren = "fill";
            dropdownGroup.margins = [10, 15, 10, 10];
            dropdownGroup.alignment = "fill";

            dropdownGroup.add("statictext", undefined, "X Alignment:");
            var xDropdown = dropdownGroup.add("dropdownlist", undefined, ["No Change", "Left", "Center", "Right"]);
            xDropdown.selection = 0;

            dropdownGroup.add("statictext", undefined, "Y Alignment:");
            var yDropdown = dropdownGroup.add("dropdownlist", undefined, ["No Change", "Top", "Center", "Bottom"]);
            yDropdown.selection = 0;

            var btnGroup = dlg.add("group");
            btnGroup.orientation = "row";
            btnGroup.alignment = "right";
            var cancel = btnGroup.add("button", undefined, "Cancel");
            var ok = btnGroup.add("button", undefined, "OK", { name: "ok" });
            ok.preferredSize.width = 80;
            cancel.preferredSize.width = 80;

            // Button event handlers
            var result = null;
            ok.onClick = function () {
                result = xDropdown.selection.text + "," + yDropdown.selection.text;
                dlg.close();
            };
            cancel.onClick = function () {
                result = null;
                dlg.close();
            };

            dlg.show();
            return result;
        }

        function processSelectedLayers(alignmentString) {
            var s2t = stringIDToTypeID;
            var ref = new ActionReference();
            ref.putProperty(s2t("property"), s2t("targetLayersIDs"));
            ref.putEnumerated(s2t("document"), s2t("ordinal"), s2t("targetEnum"));
            var layerList = executeActionGet(ref).getList(s2t("targetLayersIDs"));
            var selectedIDs = [];
            for (var i = 0; i < layerList.count; i++) {
                selectedIDs.push(layerList.getReference(i).getIdentifier(s2t("layerID")));
            }

            // Select the layers and align them
            for (var j = 0; j < selectedIDs.length; j++) {
                var r = new ActionReference();
                r.putIdentifier(s2t("layer"), selectedIDs[j]);
                var d = new ActionDescriptor();
                d.putReference(s2t("target"), r);
                executeAction(s2t("select"), d, DialogModes.NO);
                alignByMask(alignmentString);
            }

            // Re-select the original layers
            var selRef = new ActionReference();
            for (var k = 0; k < selectedIDs.length; k++) {
                selRef.putIdentifier(s2t("layer"), selectedIDs[k]);
            }
            var selDesc = new ActionDescriptor();
            selDesc.putReference(s2t("target"), selRef);
            executeAction(s2t("select"), selDesc, DialogModes.NO);
        }

        function alignByMask(userInput) {
            var parts = userInput.split(",");
            var xAlign = parts[0];
            var yAlign = parts[1];
            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;
            var bounds = activeDocument.activeLayer.bounds;
            var layerLeft = bounds[0].value;
            var layerTop = bounds[1].value;
            var layerRight = bounds[2].value;
            var layerBottom = bounds[3].value;
            var layerWidth = layerRight - layerLeft;
            var layerHeight = layerBottom - layerTop;
            var dx = 0;
            var dy = 0;

            switch (xAlign) {
                case "Left": dx = canvasLeft - layerLeft; break;
                case "Center": dx = canvasXCenter - layerLeft - layerWidth / 2; break;
                case "Right": dx = canvasRight - layerRight; break;
            }

            switch (yAlign) {
                case "Top": dy = canvasTop - layerTop; break;
                case "Center": dy = canvasYCenter - layerTop - layerHeight / 2; break;
                case "Bottom": dy = canvasBottom - layerBottom; break;
            }

            activeDocument.activeLayer.translate(dx, dy);
        }
    })();
}
activeDocument.suspendHistory("Align Masked Layers to Canvas (v1.1)", "main()");

 

studio KLOROFORM
Participating Frequently
November 8, 2023

Yes, it works. Cool

Thanks, man

Stephen Marsh
Community Expert
Community Expert
May 21, 2022

@Kssndrah – Is there any feedback on my script solution?

KssndrahAuthor
Inspiring
May 25, 2022

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.

 

Stephen Marsh
Community Expert
Community Expert
May 25, 2022

Kssndrah – I don't know which script you are having the issue with or what you have done to trigger the error.

Stephen Marsh
Community Expert
Community Expert
May 15, 2022

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.

 

 

/* 
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

 

Stephen Marsh
Community Expert
Community Expert
May 15, 2022

@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!

 

Participating Frequently
May 15, 2022

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.

Stephen Marsh
Community Expert
Community Expert
May 15, 2022

@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.

Stephen Marsh
Community Expert
Community Expert
May 15, 2022

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.

Stephen Marsh
Community Expert
Community Expert
May 15, 2022

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.

 

 

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

Participant
May 11, 2022

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.

KssndrahAuthor
Inspiring
May 11, 2022

 the proble is it selects the whole image like this

Community Expert
May 11, 2022

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

headTrix, Inc. | Adobe Certified Training &amp; Consulting
Community Expert
May 10, 2022

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

headTrix, Inc. | Adobe Certified Training &amp; Consulting
KssndrahAuthor
Inspiring
May 11, 2022

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.

 

KssndrahAuthor
Inspiring
May 11, 2022
Untitled-1.jpg