Skip to main content
Inspiring
May 25, 2017
Question

How should I continue with my plugin development?

  • May 25, 2017
  • 2 replies
  • 579 views

Currently I am a little stuck on what way to proceed.

I am looking to create a plugin that Exports .png files from each of the layers in the document. Each .png will can be exported as [PNG-24, PNG-8, Grayscale]  depending on what the user selects.

I created a Export plugin that I thought would allow me to achieve this this is what it currently does:

  • Hooks into my service client.
  • Gets the documents name.
  • Gets the documents layer count.
  • Gets the documents layer names.
  • All other logic to handle my objects

What else I need to do:

  • Save out each layer of the document to a file path.
  • Return this file path back to my service client ~ I can do this in the Export plugin

Ideally I would love to keep all this in my export plugin, I don't want to make a whole new plugin to do ONE action.

I have built out another Actions plugin, and have that ready to go.

My question is what are my next steps, do I focus on a action like this:

    error = sPSActionControl->Play

    (

      &resultDescriptor,

      eventSave,

      playDescriptor,

      plugInDialogDontDisplay

    );

What should I focus on to export these layers?

This topic has been closed for replies.

2 replies

Tom Ruark
Inspiring
May 26, 2017

You might want to look at making a generator plugin: http://blogs.adobe.com/photoshop/2013/09/introducing-adobe-generator-for-photoshop-cc.html

It can make the png's for you whenever the user modifies them.

There is also Layers to Files.jsx as JavaScript. You could convert it to C++ with some effort.

i73Author
Inspiring
May 26, 2017

So the current way I am doing it wont work? I am looking for the Artists to save out the files manually,

i73Author
Inspiring
May 26, 2017

So I'm building out my listener to listen to the actions should I extend this in my actions or is there anyway I can continue to use just my Export plugin if not can I get an explanation on why I cannot preform the action on Export plugins?

Saving out a PNG action:

SPErr PlayeventSave(/*your parameters go here*/void)

{

    PIActionDescriptor result = NULL;

    DescriptorTypeID runtimeKeyID;

    DescriptorTypeID runtimeTypeID;

    DescriptorTypeID runtimeObjID;

    DescriptorTypeID runtimeEnumID;

    DescriptorTypeID runtimeClassID;

    DescriptorTypeID runtimePropID;

    DescriptorTypeID runtimeUnitID;

    SPErr error = kSPNoError;

    // Move this to the top of the routine!

    PIActionDescriptor desc0000000000000700 = NULL;

    error = sPSActionDescriptor->Make(&desc0000000000000700);

    if (error) goto returnError;

          // Move this to the top of the routine!

          PIActionDescriptor desc0000000000000708 = NULL;

          error = sPSActionDescriptor->Make(&desc0000000000000708);

          if (error) goto returnError;

          error = sPSActionDescriptor->PutEnumerated(desc0000000000000708, keyPNGInterlaceType, typePNGInterlaceType, enumPNGInterlaceNone);

          if (error) goto returnError;

          error = sPSActionDescriptor->PutEnumerated(desc0000000000000708, keyPNGFilter, typePNGFilter, enumPNGFilterAdaptive);

          if (error) goto returnError;

          error = sPSActionDescriptor->PutInteger(desc0000000000000708, keyCompression, 9);

          if (error) goto returnError;

    error = sPSActionDescriptor->PutObject(desc0000000000000700, keyAs, classPNGFormat, desc0000000000000708);

    if (error) goto returnError;

    // Move this to the top of the routine!

    Handle aliasValue = NULL;

    FullPathToAlias("C:\Pictures\Deleteme.png", aliasValue);

    error = sPSActionDescriptor->PutAlias(desc0000000000000700, keyIn, aliasValue);

    if (error) goto returnError;

    error = sPSActionDescriptor->PutInteger(desc0000000000000700, keyDocumentID, 1121);

    if (error) goto returnError;

    error = sPSActionDescriptor->PutBoolean(desc0000000000000700, keyCopy, true);

    if (error) goto returnError;

    error = sPSActionControl->StringIDToTypeID("saveStage", &runtimeKeyID);

    if (error) goto returnError;

    error = sPSActionControl->StringIDToTypeID("saveSucceeded", &runtimeEnumID);

    if (error) goto returnError;

    error = sPSActionControl->StringIDToTypeID("saveStageType", &runtimeTypeID);

    if (error) goto returnError;

    error = sPSActionDescriptor->PutEnumerated(desc0000000000000700, runtimeKeyID, runtimeTypeID, runtimeEnumID);

    if (error) goto returnError;

    error = sPSActionControl->Play(&result, eventSave, desc0000000000000700, plugInDialogSilent);

    if (error) goto returnError;

returnError:

    if (result != NULL) sPSActionDescriptor->Free(result);

    if (desc0000000000000700 != NULL) sPSActionDescriptor->Free(desc0000000000000700);

    if (desc0000000000000708 != NULL) sPSActionDescriptor->Free(desc0000000000000708);

    if (aliasValue != NULL) sPSHandle->Dispose(aliasValue);

    return error;

}