How to center 2 layer masks at selection in photoshop

New Here ,
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

1.5K

Likes

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 Professional ,
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

Likes

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

Likes

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 Professional ,
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.

Likes

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 Professional ,
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

headTrix, Inc. | Adobe Certified Training & Consulting
Consulting | Design | Development | Training

Likes

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

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

 

Likes

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

 

Likes

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

i want to center the contents in every square

 

Likes

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.

Likes

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

Untitled-2.jpg

 the proble is it selects the whole image like this

Likes

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 Professional ,
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

headTrix, Inc. | Adobe Certified Training & Consulting
Consulting | Design | Development | Training

Likes

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.

Likes

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 Professional ,
May 14, 2022 May 14, 2022

Copy link to clipboard

Copied

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

headTrix, Inc. | Adobe Certified Training & Consulting
Consulting | Design | Development | Training

Likes

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 Professional ,
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.

Likes

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 Professional ,
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.

Likes

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.

Likes

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 Professional ,
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.

Likes

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 Professional ,
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!

 

Likes

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 Professional ,
May 15, 2022 May 15, 2022

Copy link to clipboard

Copied

LATEST

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

Y/Vertical codes:

   YT = Top

   YC = Centre

   YB = Bottom

   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.

 

CLI.png

 

/* 
Align Masked Layers to Canvas Using Mask Bounds.jsx
v1.0 - 15th 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

Info: * 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 a 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 , YT | YC | YB", "XL,YT");
        if (userInput === null) {
            //alert('Script cancelled!');
            return;
        }
        var userInput = userInput.toString().toUpperCase().replace(/[^A-Z,]/g, '');

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

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

 

Likes

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