• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get layer RGB data (C++)

Explorer ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

Hi all:

I have an Automation plugin that I'm attempting to read the RGB layer data for individual layers for. I'm able to do this on PSD files that have been exported, but looking at the Photoshop SDK, I'm not quite clear where to start if I was to do this in the Photoshop host application. I tried taking a look at the Outbound example plugin, but it looks like it relies on some sort of Globals pointer that contains an ExportRecord that's magically passed to the entry point of a export plugin.

Can I iterate over each layer in a Photoshop document and get its image data through the C++ SDK of an "Automation"-style plugin? I assume this must somehow be possible, but the documentation is not quite clear on what exactly one should do to achieve this.

TOPICS
SDK

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Adobe Employee ,
Aug 09, 2019 Aug 09, 2019

Copy link to clipboard

Copied

Can I iterate over each layer in a Photoshop document and get its image data through the C++ SDK of an "Automation"-style plugin?

-- No. Automation plugins cannot get at pixels. They need help from other plugin types.

The Outbout plugin (Export plugin type) can get at pixels. The *magic* is the plugin tells Photoshop "call me here" via the PiPL properties. For Outbound that is PluginMain in Outbound.cpp. In ExportRecordPtr, a nice big struct with all kinds of stuff, is a ReadImageDocumentDesc. ReadImageDocumentDesc is also a nice big struct, we like struct's (notice that Photoshop was invented in 1990, and has an amazing backwards compatibility story, long live C!) ReadLayerDesc and guess what...another struct, for all the layers in the document.

I had an example, AutomationFilter + Hidden that would pass the pixel data back to an automation plugin. I changed that to have the AutomationFilter give commands to the Hidden filter to keep things more isolated. The ChannelPort.8bf plugin that ships with Photoshop is a version of a *hidden* filter that does work for some automation features.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 12, 2019 Aug 12, 2019

Copy link to clipboard

Copied

Hey Tom, thanks for the response!

I'm perfectly fine with having C structs and C-style APIs. (That's my preference in any case).

If I understand correctly, then, what you're suggesting is that I have two plugins here: a filter plugin just so I have the ability to get at the data for each layer, and then pass that to the Automation plugin. Is that correct? I'll take a stab at it to see if I can get that working. If so, that would be a viable route for me to go. Right now I'm passing the data from the JSX -> C++ plugin via CSXS events, and the performance is not acceptable for my use case.

(P.S. If you have a few minutes, would you be able to take a look at my updated query in Photoshop Hybrid Extension and give some insight there as to what you think of that approach? Thanks!)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 07, 2020 Jan 07, 2020

Copy link to clipboard

Copied

LATEST

As an update: I finally found the time to manage to do this, but I have a related issue: if an end-user attempts to invoke an Automation plugin using this method while they are on a layer that normally can't have a filter applied to it (like a layer that's not visible, or a layer group), the automation plugin will fire, but the filter plugin will not, and it will fail silently with no prompt to the end-user. Is there any way that I can, at the very least, display a prompt to the end-user to notify them if the filter plugin failed to run?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines