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.
Copy link to clipboard
Copied
Here is a screenshot just for clarity.
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...
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
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.
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.
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.
Where i set align to canvas option before recording.
error i get when i have not set align settings to align to canvas.
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 Marsh or @JJMack can help you because I am not scripting guy.
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.
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.
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?
Copy link to clipboard
Copied
Regarding @Stephen 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 Marsh ; your unexpected suggestion solved it for me!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
It has always struck me as odd that anyone would want to align to selection over canvas. Maybe in a handful of situations - but the majority of the time that tool is so intrinsically about framing things up for the entire composition.....the canvas.
Copy link to clipboard
Copied
Just wanted to give this a quick bump, having this as an option in settings/preferences would be so helpful and amazing. I know it's a pretty quick step to just click the top toolbar and change 'Align to:' from Selection to Canvas, but I know I'm not alone in how much I open Photoshop on a daily basis, and those few seconds add up over the years lol.
So, if anything, this is a cry for help/feature request to implement this setting! 🙂
Copy link to clipboard
Copied
I just use Ctrl A, Select All before using the Align tools.