Photoshop publish as png

Hi @jonase,

If you’re trying to have multiple publishes of the same file, there is a little more work to be done. The behaviour you’re seeing is because the two publish plugins are overwriting each other’s properties.

When you click “publish” there are 3 phases that the publisher goes through. Validate, Publish, and Finalize. All plugins go through one phase, then the next, then the next. I’m assumming you’re using different templates for the two publish plugins. If so, the issue you’re running into works out to something like this.

Validation Phase

  1. PSD plugin validates and runs the following:["publish_template"] = publish_template   # This sets the value to the PSD template
  2. PNG plugin validates and runs the same code:["publish_template"] = publish_template   # This sets the value to the PNG template

Publish Phase

  1. PSD plugin needs a template to publish. It gets it from the item by running:
    There is only one publish_template property on the item and it was most recently set to the PNG publish template. The path for this publish is now pointing to a PNG file which is incorrect. The PSD file will actually be saved with a PNG extension. But you won’t see this because of the next step.
  2. PNG plugin gets the publish_template, which is pointing to the PNG one and this plugin works as expected.

This setup works fine when you only have one plugin publish a specific file. But when you are going to have multiple plugins, you can’t set a single value on the item because as we saw above, it will get overwritten.

You can solve this in multiple ways, but I would just stop relying on the setting from the validation phase and have each of your plugins find the correct template. You can just copy that portion of the the code from the validate method and put it in your publish methods.

    publish_template_setting = settings.get("Publish Template")
    publish_template = publisher.engine.get_template_by_name(
    if publish_template:["publish_template"] = publish_template

After you’ve done this, you should get the correct behaviour in that you get a PSD and a PNG publish (if both are checked). But there are other things you need to modify as well.

The publish phase sets another property item that is overwitten when you have multiple publishers. This is what the code looks like: = sgtk.util.register_publish(**publish_data)

The content of sg_publish_data is later used to show the log messages in the “publish compelted” UI. You’ll need to do something similar here to have each plugin store its own value in the properties and have its finalize method display the correct result.

One last thing that you might want to fix is that both your plugins will try to up-version the work file, which is not necessary. This doesn’t break because the up-version code issues a warning and moves on if the next version already exists. But it’s good to explicitly handle this and make sure only one of the plugins does the up-version process (remember that one or the other plugin can be disabled, so they both need to have the logic and maybe communicate using a different to signal that the up-version is already done)

I hope that helps you understand the mechanism better and solves your problem.