Skip to content

Commit d01358c

Browse files
committed
chore(examples): add new example for export document
1 parent 4bf5107 commit d01358c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/export_document.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Import built-in modules
2+
import os
3+
from tempfile import mkdtemp
4+
5+
# Import third-party modules
6+
import examples._psd_files as psd # Import from examples.
7+
8+
# Import local modules
9+
from photoshop import Session
10+
11+
12+
PSD_FILE = psd.get_psd_files()
13+
14+
if __name__ == "__main__":
15+
psd_file = PSD_FILE["export_layers_as_png.psd"]
16+
with Session(psd_file, action="open", auto_close=True) as ps:
17+
opts = ps.ExportOptionsSaveForWeb()
18+
19+
png_file = os.path.join(mkdtemp(), "test.png")
20+
active_document = ps.app.activeDocument
21+
active_document.exportDocument(png_file, ps.ExportType.SaveForWeb, opts)
22+
os.startfile(png_file)

0 commit comments

Comments
 (0)