If a user wanted to output multiple filetypes from Photoshop via the publish2 app, they should be able to do the following in their config:
core/templates.yml
# Add templates for each file type that they want to output. You're just copy/pasting
# the photoshop_asset_publish template, renaming it, and changing the extension on the
# path. In this case, we're setting up additional templates for png and jpg files.
photoshop_asset_publish:
definition: '@asset_root/publish/photoshop/{name}.v{version}.psd'
photoshop_asset_publish_png:
definition: '@asset_root/publish/photoshop/{name}.v{version}.png'
photoshop_asset_publish_jpg:
definition: '@asset_root/publish/photoshop/{name}.v{version}.jpg'
Once the templates are in place, you just need to create additional instances of publish_document
plugin in your config's tk-multi-publish2.yml
file:
env/includes/settings/tk-multi-publish2.yml
settings.tk-multi-publish2.photoshop.asset_step:
collector: "{self}/collector.py:{engine}/tk-multi-publish2/basic/collector.py"
collector_settings:
Work Template: photoshop_asset_work
publish_plugins:
- name: Publish to Shotgun
hook: "{self}/publish_file.py"
settings: {}
- name: Upload for review
hook: "{self}/upload_version.py"
settings: {}
- name: Begin file versioning
hook: "{engine}/tk-multi-publish2/basic/start_version_control.py"
settings: {}
- name: Publish to Shotgun
hook: "{self}/publish_file.py:{engine}/tk-multi-publish2/basic/publish_document.py"
settings:
Publish Template: photoshop_asset_publish
- name: Publish PNG to Shotgun
hook: "{self}/publish_file.py:{engine}/tk-multi-publish2/basic/publish_document.py"
settings:
Publish Template: photoshop_asset_publish_png
- name: Publish JPG to Shotgun
hook: "{self}/publish_file.py:{engine}/tk-multi-publish2/basic/publish_document.py"
settings:
Publish Template: photoshop_asset_publish_jpg
- name: Upload for review
hook: "{engine}/tk-multi-publish2/basic/upload_version.py"
settings: {}
help_url: *help_url
location: "@apps.tk-multi-publish2.location"
In the above, you'll find two additional plugin instances defined; Publish PNG to Shotgun
and Publish JPG to Shotgun
. These plugin definitions reference the new png and jpg templates that were added to templates.yml
.
Everything looks like it should work, even when you go into Photoshop and launch the Publish app. You'll see the all three of the publish plugins represented, implying that a PSD, a PNG, and a JPG will be published. When you publish, everything will succeed and you'll find three new PublishedFile entities in Shotgun!
...and then you'll notice that all three of them point to a JPG file.
This is because the Publish plugins are keyed by the file path to the associated .py
file, which is .../tk-multi-publish2/basic/publish_document.py
in this case. In the Hook
class in tk-core
, hook instances are stored in memory and reused based on their base class and hook path. We then have the publish2 app passing a list of settings to store as state on the plugin instance it gets back from tk-core
. As a result, we're in the situation of "last one wins." Because the JPG instance of the plugin was defined last in the config, ALL instances of the plugin use the JPG template.
This is broken, obviously.
Phil has a workaround, but I'm trying it and it isn't working. Looking at code, it seems like it should, so I'm very confused. We might need Phil to chime in early next week to see what I've done wrong. :(
I have been trying the workaround and still get the same result.
I have completely segregated every hook:
Within those hooks, I have renamed the plugin
class
as well.I added a folder to
templates.yml
for the output path as well:Still get only the single JPG (now in the jpg folder.)
I will also double-check with Phil, just wanted to note exactly what I tried above.