ENGLISH

PS-Scripting – Professional Photoshop Scripting

Book information

Publisher
Davide Barranca
Year
2019
Language
english
Format
PDF
Filesize
26 MB (26834039 bytes)
Edition
1.0
Pages
408\408
Topic
Computers\\Programming
Time added
2021-11-10 14:11:16

Description

Source: https://www.ps-scripting.com/ps-scripting.html From Beginner to Professional ► Optimize your learning curve with a complete, in-depth Course +400 pages strong. ► All aspects covered to develop production-ready Scripts. ► Suitable for beginners and experienced developers alike. ► Exclusive coverage of advanced topics not found anywhere else. ► Examples and demo code for everything! I've carefully designed a learning path that guides you through all the aspects of Scripting development: from the tools to the syntax, up to very advanced topics which aren’t found anywhere else in such great detail. Not kidding! E.g., 70 pages on ActionManager, and 60 pages on Adobe Generator plug-ins! Do you know what’s missing in the official documentation? Examples, examples, and more examples. I’ve packed this course with demo code on real-world problems. Foreword ......................................................................................................................................... i Course presentation ...................................................................................................................... ii Why I wrote this book ............................................................................................................. ii Audience and Assumptions .................................................................................................... iii What you need to get started ................................................................................................... iv Conventions .............................................................................................................................. v Version History and Errata ....................................................................................................... v 1.0.0 .............................................................................................................................. v 0.2 EAP ......................................................................................................................... v 0.1 EAP ......................................................................................................................... v Feedback ................................................................................................................................. vi Piracy ...................................................................................................................................... vi Content at a glance ...................................................................................................................... vii 1. Photoshop Scripting ............................................................................................................... 1 1.1 Photoshop Extensibility overview ................................................................................4 Actions .......................................................................................................................... 4 Scripting ........................................................................................................................ 6 HTML Panels ................................................................................................................ 6 Plug-ins (Photoshop SDK) ............................................................................................ 7 1.2 How Scripting works .................................................................................................... 8 1.3 Languages and Documentation ...................................................................................11 ExtendScript vs. JavaScript ........................................................................................11 Photoshop and Core ExtendScript ..............................................................................12 Documentation ............................................................................................................ 13 JavaScript Primer for starters ...................................................................................... 14 2. Writing Scripts ..................................................................................................................... 16 2.1 Files, Extensions and Folders ..................................................................................... 16 2.2 Adobe ExtendScript Toolkit .......................................................................................16 2.3 Better Code Editors ..................................................................................................... 22 2.4 Running Scripts ........................................................................................................... 23 CONTENTS 3. Hello World by Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.1 The Great-Grand Father of all Greetings . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.2 An Average problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.3 Layers Spring cleaning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.4 ESTK debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.5 Homeworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 4. Climbing the DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 4.1 The Tree of Scripting Life . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 4.2 Collections, Classes and Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 4.3 Scripting practice with Algorithmic Art . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.4 Layers and LayerSets: the DOM approach . . . . . . . . . . . . . . . . . . . . . . . . . 77 4.5 Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 5. The ExtendScript Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.1 Old but Gold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.2 The Dollar object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 5.3 The Reflection Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 5.4 Preprocessor Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 5.5 Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 5.6 Notification Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 5.7 XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 5.8 Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 5.9 Graphic User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 5.10 External Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 5.11 XMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 5.12 Localization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 5.13 Operator overloading, Constants and UnitValue . . . . . . . . . . . . . . . . . . . . . 118 6. Action Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.1 Action Manager is not the DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 6.2 Action, Events, and historical perspective . . . . . . . . . . . . . . . . . . . . . . . . . 122 6.3 ScriptListener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 6.4 charIDs and stringIDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 6.5 ActionDescriptors and DialogModes: executeAction . . . . . . . . . . . . . . . . . . . 131 6.6 Building AM functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6.7 Extending the DOM with Action Manager . . . . . . . . . . . . . . . . . . . . . . . . . 138 6.8 Nested Descriptors and ActionLists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 6.9 Getting data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 6.10 ActionReference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 6.11 Inspecting Descriptors: executeActionGet . . . . . . . . . . . . . . . . . . . . . . . . . 153 Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 CONTENTS Descriptor Inspectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 ActionSets and Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 6.12 Getting Descriptors as Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 6.13 AM Setters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 7. User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 7.1 The technology dilemma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Behaviour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Appearance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Technology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 7.2 ScriptUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 7.3 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 7.4 The Window object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 7.5 Containers and Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 7.6 Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Orientation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 align and alignChildren . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Margins and Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 7.7 Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 7.8 Components minimal reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 7.9 Events, and Event handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Window and Controls Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Event Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Event Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 Create and Simulate Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 7.10 Styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 Custom elements and onDraw() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 7.11 Putting it all together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 7.12 CEP Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 8. Working with Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 8.1 XMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Schemas and Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 XMPFile, XMPMeta, and XMPProperty . . . . . . . . . . . . . . . . . . . . . . . . . . 267 Editing the XMP Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272 Custom Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Per Layer Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 CONTENTS 8.2 Generator Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 8.3 Photoshop Registry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 8.4 External Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 JSON Example: saving the GUI status . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 XML Example: a complete Preset system . . . . . . . . . . . . . . . . . . . . . . . . . . 290 9. Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 9.1 Script Events Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 9.2 Notifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 10. Adobe Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 10.1 Plug-In development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Generator Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Document Info Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 10.2 Network Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 10.3 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318 10.4 Generator to JSX Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Using external .jsx files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 10.5 Bitmaps and Pixmaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 Pixmap Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 10.6 Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 10.7 Connecting to external services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 Artificial Intelligence: Face Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 10.8 Socket.io Server/Client communication . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Sockets 101 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Generator as a Server: CEP Panel interaction . . . . . . . . . . . . . . . . . . . . . . . 349 Generator as a Client: Photoshop remote control . . . . . . . . . . . . . . . . . . . . . 356 10.9 The Kevlar API for Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365 11. Cross-Application Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 11.1 Cross-DOM API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 Startup Scripts folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 11.2 BridgeTalk concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 Static Methods and Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 The BridgeTalk Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 Synch and Asynch behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 11.3 Event handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374 DOM Objects returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 Receiving messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376 Sending intermediate responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380 11.4 Wrap-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 12. Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 CONTENTS 12.1 Deploying Scripts ..................................................................................................... 384 Testing ........................................................................................................................... 384 Obfuscation ............................................................................................................... 385 Installation ................................................................................................................ 387 12.2 Resources .................................................................................................................. 389 Adobe’s Official ....................................................................................................... 389 Third-party Documentation ......................................................................................389 Third-party Forums and Groups ...............................................................................389 Software Developers’ websites .................................................................................389 ScriptUI ..................................................................................................................... 390 Text Editors Plug-ins ................................................................................................. 390 Libraries, Frameworks, and Repositories .................................................................390 Books ........................................................................................................................ 390 Acknowledgments ..................................................................................................................... 391 Bio ............................................................................................................................................... 392 Davide Barranca – Author .................................................................................................... 392 Sandra Voelker – Technical Editor .......................................................................................392

Similar books