Writing Export Plug-ins

Export plug-in modules are used to output an image from an open Photoshop document.

Export modules can be used to print to printers that do not have Mac OS Chooser-level driver support.

They can also be used to save images in unsupported or compressed file formats, although File Format modules often are better suited for this purpose. File Format modules are accessed directly from the Save and Save As commands, whereas Export modules use the Export sub-menu.

For descriptions of the sample Export plug-ins provided with the SDK, see Export Samples.

When the user invokes an Export plug-in by selecting its name from the Export submenu, Photoshop calls it with the sequence of selector values shown in the figure below. The actions the Export plug-in needs to take for these selectors are discussed in more detail in Export Module.

Note:
Your plug-in should validate the contents of its globals and parameters whenever it starts processing if there is a danger of it crashing from bad parameters.

Export Modules and Scripting

The scripting system passes its parameters at every selector call. While it is possible to use the scripting system to store all your parameters, for backwards compatibility, it is recommended you track your parameters with your own globals. Once your globals are initialized, you should read your scripting-passed parameters and override your globals with them. The most effective way to do this is:

  1. First call a ValidateMyParameters routine to validate (and initialize if necessary) your global parameters.
  2. Then call a ReadScriptingParameters routine to read the scripting parameters and then write them to your global structure.

This way, the scripting system overrides your parameters, but you can use the initial values if the scripting system is unavailable or has parameter errors, and you can use your globals to pass between your functions.

Scripting at exportSelectorFinish

If your plug-in is scripting-aware and it has changed any initial parameters, it should pass a complete descriptor back to the scripting system in the PIDescriptorParameters structure.

Advance State and Export Modules

The AdvanceStateProc can be called from either exportSelectorStart or exportSelectorContinue and will drive Photoshop through the process of allocating and loading the requested buffer. Termination is reported as userCanceledErr in the result from the advanceState call. Calling advanceState when theRect or theRect32 is empty results in nothing.