I want to record an action where i use the width of one layer (variable a) as an input in the action - so that I can select that another layer uses that variable a to place the layer on the canvas (I want X of layer 2 to be equal to variable a).
Is this possible?
Copy link to clipboard
No it is not possible with an action, however, it is possible with a script.
Ok, thanks! Then I'll have to decide whether it's worth figuring how to write a script or just do it manually 🙂
Yes, that is always the case, life is full of trade offs, Photoshop is no different.
will there always be the same quantity of layers in the same positions with the same names?
If you can post a cropped screenshot of your layers panel and perhaps an image of two layers as a before and after that may assist anybody willing to help code this. If you have an action sharing that would help, even if it can't do 100% of what you require.
🙂 Sooner or later I guess I will work out how to make script in PS (I have used it in eg Excel, but don't know whether the PS version is very similar).
Anyway, this is my situation: I have many jpg files (of calendar pages) that I want to paste togeter two and two (front and back) and saves as a jpg. Currently (as I am not using any script) I do it this way:
I select the two pages I want to paste together (I have 1000's of these pairs...) in Windows Explorer and drag to PS.
I check what the width of the canvas is of the page that is to be on the left of the combined page (in this case 3145 px) (this number is similar, but not identical, for all the pages).
I then go to the tab of the page that is to be on the right, and click on the layer (named Bakground) of this and drag to the window with the first page. While this layer is still selected, under Tranform in the properties panel I type 3145 for X, then tab to Y and type 0, then enter.
I then press ctrl +7 to run my action as follows:
This expands the canvas to accomodate both original pictures, side by side, Add a background to make up for if one of the original pictures is higher than the other, then Trim, flatten and save (in the name of the first picturer) and close both windows.
Anything I can do to cut steps (including e.g. automatically deleting the second file as the picture has been pasted into the first) would be of help.
Can you provide example file names of 2 x 2 "pairs", such as:
The final result would look something like this (obviously both pages would be different)?
Do you really need the file to be exactly "even" in width? Resampling is destructive. What if you just combined both pairs of images and the left and right pages were slightly different in width, would that be a problem (the middle join would be slightly off centre to the file)?
It sounds like each combined set of image pairs is slightly different in size to the next anyway... Do you wish to have the left and right pages evenly centred?
Open the two documents with the left scan as the front document and try this script:
#target photoshop preferences.rulerUnits = Units.PIXELS; var d1 = app.documents; var d2 = app.documents; var sprd = d2.duplicate(d1.name + "-" + d2.name,true) sprd.resizeCanvas(d1.width+d2.width, d2.height, AnchorPosition.TOPRIGHT); app.activeDocument=d1; d1.layers.duplicate (sprd);
A pair of single layer docs with the left page active. The two docs have different pixel widths:
after running the script: