Vector Mask support #177
Replies: 1 comment 2 replies
-
|
Hey @reddesignsguy, I appreciate you being interested in improving the PhotoshopAPI! Vector masks has been something on the (mental) backlog for a long time so I'm happy to see someone tackle it. Gotchas/starting informationI'll start with the gotchas/starting information and go from there. I think the main thing to be aware of when working with the PhotoshopAPI is that it follows 2-step parsing. 1: The Photoshop file is first parsed pretty much verbatim into the 2: This This is probably the main thing to keep in mind when you are writing the parsers for the layer masks. You will both need to implement the parser for the vector mask tagged blocks (as well as modifying anything on the LayerInfo struct to accomodate these changes if necessary), and the user-facing interface for dealing with vector masks that is a bit abstracted away from what photoshop does under the hood. Entry points for your codeHere I'll give some links to the main entry points in the code to look at, but I would highly encourage taking one of the examples in the repo and stepping through the reading of a file with a debugger to get a feel for the flow Tagged BlocksTo add a new tagged blocks there's two things you need to do. You will need to implement a parser for the VectorMaskTaggedBlock similar to this one: Once you have done so you'll need to add it to this file to actually have it read out as the PhotoshopFile parses: Registering with the layerOnce the tagged block is there, you will need to parse it from the PhotoshopFile -> LayeredFile as handled by this constructor: You'll likely need to modify the MaskMixin to support vector masks RoundtrippingTo then roundtrip back for write, you'll need to modify this function here to generate the tagged blocks for the mask data. Note You may need to do this for all derived layers (SmartObjectLayer, GroupLayer, ImageLayer) as that code is not too clean at the moment. Resources and ToolingYour main resource will likely be these two:
As for tooling to actually read the binary structure visually, I developed this some eons ago when I initially started working on the PhotoshopAPI. It is a parser for a vscode plugin that allows you to inspect the structure of the file by expanding/collapsing sections. This isn't a full parser by any means but will organize the file a bit better than just looking over the binary file https://github.com/EmilDohne/PhotoshopFileInspector/ Closing remarksAs a final note to you, the PhotoshopAPI is by no means perfect and I initially started it when I was not very experienced with C++. I have since gotten better but a fair bit of the codebase still does some questionable things. As I add features I usually also try to cleanup wherever possible but if you see something weird it may not always be on purpose. Godspeed! Let me know if there is any additional questions/guidance you need :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Emil,
I'd like to contribute by supporting vector masks. What sections of the code do you think I should look at? And are there any gotchas I should know?
Here's some info I gathered:
Additional Layer Informationand are indictated via thevmskkey/src/util/Enum.hcurrently lists thevmskkey but is unsupportedTaggedBlockcorresponds to blocks in theAdditional Layer Information-- Seems like this will be the main component of implementing this taskPath Resource Formatis used to define the actual path information, however, this can be used in 2 different sections:Additional Layer Informationfor per-layer vector masks andImage Resourcesfor document-wide working/saved paths.. will probably need to keep future-proofing in mindBeta Was this translation helpful? Give feedback.
All reactions