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

Use width of a layer as input in recorded action

Contributor ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

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?

TOPICS
Actions and scripting

Views

470

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

correct answers 1 Correct answer

Community Expert , Feb 06, 2021 Feb 06, 2021

No it is not possible with an action, however, it is possible with a script.

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

No it is not possible with an action, however, it is possible with 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
Contributor ,
Feb 06, 2021 Feb 06, 2021

Copy link to clipboard

Copied

Ok, thanks! Then I'll have to decide whether it's worth figuring how to write a script or just do it manually 🙂

 

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 ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

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.

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
Contributor ,
Feb 07, 2021 Feb 07, 2021

Copy link to clipboard

Copied

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

PS2.JPG

 

 

 

 

 

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:

Action.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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.

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 ,
Feb 08, 2021 Feb 08, 2021

Copy link to clipboard

Copied

Can you provide example file names of 2 x 2 "pairs", such as:

 

Cal-00001A.jpg

Cal-00001B.jpg

Cal-00103A.jpg

Cal-00103B.jpg

 

The final result would look something like this (obviously both pages would be different)?

 

combined.jpg

 

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?

 

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 ,
Feb 09, 2021 Feb 09, 2021

Copy link to clipboard

Copied

LATEST

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[0];
var d2 = app.documents[1];

var sprd = d2.duplicate(d1.name + "-" + d2.name,true)    
sprd.resizeCanvas(d1.width+d2.width, d2.height, AnchorPosition.TOPRIGHT);

app.activeDocument=d1;
d1.layers[0].duplicate (sprd);

 

 

A pair of single layer docs with the left page active. The two docs have different pixel widths:

 

Screen Shot 17.png

 

after running the script:

 

Screen Shot 18.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