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

Align to Selection / Canvas - Photoshop

Explorer ,
Nov 09, 2020 Nov 09, 2020

Copy link to clipboard

Copied

Good morning everyone,
Is there a way to make photoshop open (from launch) to have the "align to" set to Canvas instead of defaulting to "selection"?

I am just curious, because we work with action sets that call for "Align to Canvas", and the actions always stop when this is not set; but if i can make photoshop "Align to Canvas" as default, we should not have this issue any longer.

 

Your input in this will be greatly appreciated.

TOPICS
Actions and scripting , Windows

Views

3.0K

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
Explorer ,
Nov 09, 2020 Nov 09, 2020

Copy link to clipboard

Copied

Here is a screenshot just for clarity.
Photoshop Alight To.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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Why not insert a select all before the align step, then a deselect afterward? Then the default option to align to selection will align to the canvas.

 

Otherwise you could replace the action step with a call to a script...

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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

This script code aligns to the canvas:

 

 

// Align Active Layer to Canvas.jsx

/* https://community.adobe.com/t5/photoshop/align-to-selection-canvas-photoshop/m-p/11582354 */

/* 
ADSLefts      =   Align Left
ADSRights     =   Align Right
ADSCentersH   =   Align Centre Horizontal
ADSTops       =   Align Top
ADSBottoms    =   Align Bottom
ADSCentersV   =   Align Centre Vertical
null          =   insert "null" to quickly disable one of the two alignment options
*/

align2Canvas(true, true);
function align2Canvas(alignToCanvas, alignToCanvas2) {
    var c2t = function (s) {
        return app.charIDToTypeID(s);
    };
    var s2t = function (s) {
        return app.stringIDToTypeID(s);
    };
    var descriptor = new ActionDescriptor();
    var descriptor2 = new ActionDescriptor();
    var reference = new ActionReference();
    var reference2 = new ActionReference();
    reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
    descriptor.putReference(c2t("null"), reference);
    // Align Top
    descriptor.putEnumerated(s2t("using"), s2t("alignDistributeSelector"), s2t("ADSTops")); // Align Top
    descriptor.putBoolean(s2t("alignToCanvas"), alignToCanvas);
    executeAction(c2t("Algn"), descriptor, DialogModes.NO);
    reference2.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
    descriptor2.putReference(c2t("null"), reference2);
    // Align Left
    descriptor2.putEnumerated(s2t("using"), s2t("alignDistributeSelector"), s2t("ADSLefts")); // Align Left
    descriptor2.putBoolean(s2t("alignToCanvas"), alignToCanvas2);
    executeAction(c2t("Algn"), descriptor2, DialogModes.NO);
}

 

 

While this script code aligns to a selection created by the script:

https://gist.github.com/MarshySwamp/df372e342ac87854ffe08e79cbdbcbb5

 

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

 

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 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Good afternoon Stephen,
I may have worked this a little backwards, but have hundreds of actions to update then!
I will try a couple with the "Select All" becasue what I did was select each layer with "Shift Click" instead of "Select All". This may very well solve my problem. I will let you know how it goes.

I might also just try out the script though! That looks very exciting.

 

Regards,
Keith.

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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

How are your Action record.  When I want to align layer to the canvas I have always recorder  "Select All" then Align layers to selection.  I did not see as way to record a layer alignement with out a selection.   So what is the action step that fails. How does your action recorad align to canvas. All I see in layers nenu is align to selection. I do the same in Scripts and use action managet code to do the alignment.

image.png

 

JJMack

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 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Hi JJMack, 
Good to hear from you again! Thanks for your response.
So when ever i start a new document in photoshop I set my alight option from "selection" to "canvas" (Screenshot attached). This is probably why I keep getting a break in my actions if my alight option is set to "selection" when i run the actions.

 

Action Set.
Step 1.jpg

 

Where i set align to canvas option before recording.

Step 2.jpg

error i get when i have not set align settings to align to canvas.

Step 3.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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

This option is sticky for session, from what I can see so you need script to change to Canvas whenever you run Photoshop, right? That could be possibly done using File > Scripts > Script Events Manager. Of course you need script for that task. Perhaps @Stephen_A_Marsh or @JJMack  can help you because I am not scripting guy.

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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Hi Bojan,

 

I couldn't work out how to preset the selection/canvas option via scripting (perhaps somebody else can, sometimes things just can't be scipted) and it appears to keep defaulting to selection.

 

So, the pragmatic approach is to simply record a select all command into the action before the align steps, then a deselect after the alignment steps.

 

Otherwise, the two scripts that I posted are self-contained, they will either align to canvas or selection, depending on which script is used. I have documented the various alignment option code names and where to change them in the script so that one can hard code in the required alignment steps. The script assumes both a vertical and horizontal movement, but one can simply replace one of the alignment codes with "null" (including the double quotes) to disable that step without having to make major code changes.

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 ,
Nov 10, 2020 Nov 10, 2020

Copy link to clipboard

Copied

Ok, this is why my thoughts came out loud: "I may have worked this a little backwards, but have hundreds of actions to update then!"

The only way I can think of is to change to Canvas via script if possible because it will remain default for that session but not when Photoshop is restarted. Hovewer, from what I see this is not that big deal because if someone is using lots of actions then changing one option before anything else should not be such pain.

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 ,
Jun 22, 2022 Jun 22, 2022

Copy link to clipboard

Copied

Bump... Does anybody have any AM code to ensure that the move tool option to align to canvas has been activated and is not left on selection?

 

canvas.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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

Regarding @Stephen_A_Marsh 's last post in 2022, I don't come here with any scripting answers, but just to say that his initial suggestion to record a Select All, then the alignments, then a Select None worked brilliantly for me… and I was surprised and a little embarrased that I didn't interpret "selection" to mean a literal marquee selection of the entire canvas.

 

I found this thread because I was having the same exact issue: I recorded an action that took a layer from one document, copied and pasted it into another open document, then ran some transforms (and alignments) on it, before flattening, resizing, saving and closing that document. When playing back the action on a fresh start of Photoshop, I got the same error as @Q0093C-PC .

 

When I recorded my alignment events, I just used the little toolbar flyout like @Q0093C-PC did, changing "Selection" to "Canvas" in the first step as I only had one layer selected in the Layers panel. I've used both align-to-selection and align-to-canvas manually hundreds of times—sometimes alternating between the two during the same session. But because I "selected"—in the Layers panel—everything I wanted to align together (e.g., a line of text vertically and horizontally centered within a rectangle shape), that became my personal definition and understanding of the term "Selection."

 

So to be clear, the subsequent steps in my set of actions, after the paste-into-open-document step, were Transform (to scale it down to the fit within the smaller canvas size of the open document), then Align (to center the layer horizontally and vertically within the canvas). The layer being scaled and positioned was a Smart Object, and the pasting and transforming left it most of the way off the canvas. So regardless of the layer's contents being outside the canvas boundaries, it still aligned itself to the canvas' marching ants selection. Genius.

 

Anyway, thank you @Stephen_A_Marsh ; your unexpected suggestion solved it for me!

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 ,
Apr 02, 2024 Apr 02, 2024

Copy link to clipboard

Copied

LATEST

@dugfresh36 

 

Thanks for the feedback and follow up.

 

I wish that actions and scripts recorded the choice of either selection or canvas. So by performing a select all, the alignment will always have something canvas sized to align to, regardless of canvas or selection being set in the interface.

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