Edit in GitHubLog an issue

Getting started

Download the SDK

Begin by downloading the UXP Hybrid plugin SDK from Developer Console (here is what to do if you get “Access Denied”). Unpack the contents and make sure you check out the README.md. There are special instructions for building and packaging a hybrid plugins since they are different from a standard UXP plugin.

The concept of a hybrid plugin is very similar to Node.js C++ Addons. The dynamically linked shared objects written in C++ are available to JavaScript. template-dev walks you through a very basic example that illustrates how the two worlds communicate.

Samples

Try the ready-to-use template-plugin provided within the SDK to say a quick ‘Hello world!’. Load the template via UDT, and find it under the Plugins menu.

Plugins menu

Debug

UXP Hybrid plugin has both - JavaScript and C++. Use the UDT Debug tool for setting breakpoints for JavaScript.

For debugging C++ code, you must attach to the Photoshop.exe process via the IDE. In most IDEs you can find that option under Debug -> Attach to Process.

However, in macOS you have to perform a prior step. Follow the guide to debug in macOS.

Known Issues

While loading your plugin via the UDT, it may not show your plugin in Photoshop automatically. Uncheck and check the plugin name from the ‘Plugin’ menu item to launch it. The fix for this is expected in a future macOS release.

File system access

With the hybrid plugins, we have relaxed the UXP sandbox restrictions. You can access the file system in the following way:

Copied to your clipboard
1let entry = '/path/to/target.psd';
2document.saveAs.psd(entry);

This is opposed to a standard UXP plugin’s method of accessing the file system:

Copied to your clipboard
1let entry = await require('uxp').storage.localFileSystem.getFileForSaving("target.psd");
2document.saveAs.psd(entry);

Photoshop C++ SDK

Photoshop offers a number of C based plugin APIs. These are documented in the downloadable package. A hybrid plugin can get access to these APIs by exposing an additional function entry point.

Copied to your clipboard
export SPErr PSDLLMain(const char* selector, SPBasicSuite* basicSuite, PIActionDescriptor descriptor);

After Photoshop loads a hybrid addOn, it will invoke this method. The basicSuite argument can be used to obtain Photoshop API suites. See the C++ SDK for information about how to acquire Photoshop suites.

Sample code:

To test this, you can add the following to module.cpp from the hybrid plugin sample:

Copied to your clipboard
1// Photoshop SDK includes (add path to project)
2#include "SPBasic.h"
3#include "PIColorSpaceSuite.h"
4
5. . .
6
7// ----------------------------------------------------------------------------------------------------
8static const SPBasicSuite* gBasicSuite = nullptr;
9static const PSColorSpaceSuite2* gColorSpaceSuite = nullptr;
10
11extern "C" UXP_EXTERN_API_STDCALL(SPErr) PSDLLMain(const char* selector, SPBasicSuite* spBasic, void*)
12try {
13 do {
14 if (spBasic == nullptr)
15 break;
16
17 // cache the basic suite so we can use at any time
18 gBasicSuite = spBasic;
19
20 SPErr spErr = gBasicSuite->AcquireSuite(kPSColorSpaceSuite, kPSColorSpaceSuiteVersion, reinterpret_cast<const void**>(&gColorSpaceSuite));
21 if (spErr != kSPNoError)
22 break;
23
24 if (gColorSpaceSuite == nullptr)
25 break;
26
27 Color8 colorArray[1] = {11, 30, 201, 0};
28 spErr = gColorSpaceSuite->Convert8(plugIncolorServicesRGBSpace, plugIncolorServicesCMYKSpace, colorArray, 1);
29 if (spErr != kSPNoError) break;
30 } while (false);
31
32 return kSPNoError;
33}
34 catch(...) {
35 return -1;
36}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.