Copy link to clipboard
Copied
In my plugin I have code which checks whether a background layer is available:
#include <PIActions.h>
#include <PISuites.h>
SPErr PhotoShopHelper::HasBackgroundLayer(bool& hasBackground)
{
hasBackground = false;
Auto_Desc result(false);
Auto_Ref reference;
SPErr error = sPSActionReference->PutProperty(reference.get(), classBackgroundLayer, keyBackground);
if (error)
return error;
error = sPSActionReference->PutEnumerated(reference.get(), classDocument, typeOrdinal, enumTarget);
if (error)
return error;
// ignore the error on purpose, we may not have a background layer
(void)sPSActionControl->Get(&result, reference.get());
if (result.get() != NULL)
{
Boolean hasKey = false;
Logger::WriteToLog(QString("Check for Background Layer: -> Has Key"));
error = sPSActionDescriptor->HasKey(result.get(), keyName, &hasKey);
if (error)
{
return error;
}
if (hasKey)
{
hasBackground = true;
}
}
return error;
}
Until Version 24.6, The HasKey returned true if there is a background-layer available.
In Version 24.7, it will return true only if there is another layer (or more) available. If there is only a background-layer, it will return false.
Expectaition would be that it will return true in all cases a Background-layer is availabe (as before 24.7)
Copy link to clipboard
Copied
Hello,
I don't think there's any need for further testing after this line of code:
if (result.get() != NULL)
You are trying to retrieve a background layer. And if there is no background layer Photoshop will return NULL in result.
I haven't tested it on version 24.7. But my validation code ends at this line and everything works fine in version 25.2 with both single and multiple layers (with background layer present and absent).
Copy link to clipboard
Copied
This is correct, but the error appeared when there is only(!) a background-layer.
Anyway:
It seems to be fixed in the newer Versions of Photoshop (at least the problem does not appear anymore), so the problem is only in 24.7.0
Copy link to clipboard
Copied
Ah, the typical Photoshop API. 🙂
I can confirm from my experience that Photoshop has a strange, sometimes illogical, and incomplete C++ API.
Offtopic:
I found your post about porting the plugin to Windows. I have a slightly different problem. I am trying to port my Photoshop plugin from Windows to Mac. I'm very new to Mac and don't fully understand how things work there. My build system is also based on CMake and I was able to compile a binary dylib file, but judging by the examples, the plugin should be something like a folder with files (bundle?). Could you share an example of a CMake file that creates this folder structure? Also, it would be great to see your list of parameters for Rez (the Xcode project doesn't give detailed information about what parameters are used to compile the resource).
Copy link to clipboard
Copied
First: Can you open a new Thread for this?
Because then also other people can find it and help - I think here it will be lost forever
And I think it is also interesting for others. I have also not fully understand it, I took over our plugin from another person and the pipeline was allready there 🙂
Are you refering to this one?
https://community.adobe.com/t5/illustrator-discussions/how-to-build-an-illustrator-c-plugin-with-cma...
This is about Illustrator, and I found the API to be completely different from the one of Photoshop
However, on Mac, the plugin is a container, which includes all the libraries it is using. It is like any other application for Mac.
This one explains it for Illustrator, but the package should look nearly the same for Photoshop:
https://community.adobe.com/t5/illustrator-discussions/error-loading-plugin-ported-from-windows-to-m...
The Name of the container should be <Plugin>.plugin, containing an "executable" of the name "Plugin" in Contents/MacOS
Copy link to clipboard
Copied
I was referring to this thread: https://community.adobe.com/t5/illustrator-discussions/how-to-build-an-illustrator-c-plugin-with-cma...
Actually, after entering the name of a new topic, the site suggested this thread: https://community.adobe.com/t5/photoshop-ecosystem-discussions/moving-from-xcode-to-cmake-photoshop-...
Also, after googling some of the details from that thread, I found this repository: https://github.com/phruse/photoshop-plugin-starter/tree/b02829da49bb361ee06755814f8f640ba6cbdb59
So, I think I've already found a solution, but I still need to test it.
Also, thank you for some clarifications on the structure of the plugin.