Highlighted

Align to Selection / Canvas - Photoshop

Explorer ,
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, Feature request, How to, Windows

Views

90

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

Align to Selection / Canvas - Photoshop

Explorer ,
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, Feature request, How to, Windows

Views

91

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

Copy link to clipboard

Copied

Here is a screenshot just for clarity.
Photoshop Alight To.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
Reply
Loading...
Nov 09, 2020 0
Adobe Community Professional ,
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...

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
Reply
Loading...
Nov 10, 2020 1
Adobe Community Professional ,
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

 

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
Reply
Loading...
Nov 10, 2020 0
Explorer ,
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.

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
Reply
Loading...
Nov 10, 2020 0
Most Valuable Participant ,
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

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
Reply
Loading...
Nov 10, 2020 1
Explorer ,
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

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
Reply
Loading...
Nov 10, 2020 0
Adobe Community Professional ,
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.

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
Reply
Loading...
Nov 10, 2020 1
Adobe Community Professional ,
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.

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
Reply
Loading...
Nov 10, 2020 1
Adobe Community Professional ,
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.

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
Reply
Loading...
Nov 10, 2020 1