Copy link to clipboard
Copied
Hi,
I have a script that opens up files of specific type from a folder. What I need to automate is:
- Open the file
- Wait until the document is loaded and its content is visible
- Take a screen shot at the above point
- Close this document
- Repeat the above process for next file
Here's what I came up to achieve this
open(file)
$.sleep(1000)
takescreenshot(file.name)
$.sleep(1000)
doc.close(SaveOptions.DONOTSAVECHANGES)
where takescreenshot() calls a batch file to capture the screen at this moment. But the script is not solving its purpose - I get an unloaded document in the screenshot captured. I have 3 questions:
1. Is there any provision to wait till the document is loaded?
2. Is there any provision to capture the document window without depending on an external script to do so?
3. Is there a better way to achieve this task
SO Link: javascript - Taking a screenshot in Photoshop script - Stack Overflow
Copy link to clipboard
Copied
Do you have a reason to take a screenshot, i.e. having Photoshop UI included in the shot? Can you explain what you are trying to achieve more closely. Why do you take a screenshot of a file you load to be saved to a file, what changes?
In general I'd recommend to use Photoshop scripting to automate what you would do manually in Photoshop like
1) Open template document
2) Open content document
3) Duplicate content layer in template and position it
4) Duplicate template doc
5) Flatten the duplicate and save to disk
6) Delete content layer from template and close content doc
7) go to 1)
Copy link to clipboard
Copied
Thanks for the response Matias.
I am trying to compare a set of files based on how they are rendered in PS vs how they are rendered in some other application. I don't intend to save the file again, was just opening it. I fear that the output I get on flattening the doc might be different from what is seen when the document is opened. Could that happen, or should I go ahead with the flattening workflow?
Copy link to clipboard
Copied
I would say flattening is more reliable, i.e. then it does a render to specific resolution and should work the same way in any computer with same version of PS. However screenshot depends on monitor resolution, window size, possibly even graphics card drivers (i.e. if Photoshop is compatible with using HW acceleration in your card or not). Try zooming a bigger than screen doc in and out and you'll see pretty big distortions depending on zoom level. I'd try.
Copy link to clipboard
Copied
But the question is how not why.
Copy link to clipboard
Copied
Try adding an app.refresh() after opening your documents.