Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting masks as pixmaps or vectors #161

Open
marekhrabe opened this issue Mar 8, 2014 · 12 comments
Open

Exporting masks as pixmaps or vectors #161

marekhrabe opened this issue Mar 8, 2014 · 12 comments

Comments

@marekhrabe
Copy link
Contributor

This is the last type of data that are stored in PSD, we have their metadata available in JSON, but can't be actaully exported, as far as I know, to formats like PNG or SVG. Are there any plans to support this?

@marekhrabe
Copy link
Contributor Author

Any opinions on this please?

@timothynoel
Copy link

You can get the vector masks via getLayerShape, the pixel masks aren't supported yet, but we could in the future.

@joelrbrandt
Copy link
Contributor

@marekhrabe Just FYI, the getLayerShape API is new in generator-core version 3.0 and up. It will ship with the next version of Photoshop.

https://github.com/adobe-photoshop/generator-core/blob/master/lib/generator.js#L746

I'm marking this as a feature request so that we can prioritize it appropriately and hopefully get pixel masks (and, pixel representations of vector masks) supported in the near future

@joelrbrandt
Copy link
Contributor

@marekhrabe I also should note that the getLayerShape API should work fine with older versions of Photoshop (e.g. 14.2.1). However, that API call won't actually be in a bundled version of PS/Generator until the next release of PS.

@marekhrabe
Copy link
Contributor Author

It would be nice to be able to export masks as we would like to export unmasked image and it's mask separately and join them later in our app. Can I help somehow to implement this?

@joelrbrandt
Copy link
Contributor

@marekhrabe You can apply for a job at Adobe. :-) Unfortunately, getting a pixel mask requires a change on the native side. I assume the vector mask stuff is already working for you?

@timothynoel when you come up for air, could you weigh in on what the timeline might look like for adding the ability to get pixel masks (and an unmasked version of the regular layer pixels)? I'm happy to do the legwork on the JS side (post-15.2. obviously). Thanks!

@timothynoel
Copy link

I think you could disable the masks with a "layerSettings" array/dict. I don't have the format/exact code handy though. Returning the mask though would need some extra work. Mostly just connecting the Generator API with the Photoshop library API that already supports this.

@marekhrabe
Copy link
Contributor Author

I have tested or looked up the things we are takling about and this is the state of any kind of mask support:

  • Getting layer pixmap with it's own mask applied (this is default generator.prototype.getPixmap behavior)
  • Getting layer pixmap with all relevant masks applied (via includeAncestorMasks option you implemented for me back in the days 👌)
  • Getting path data from vector masks (via generator.prototype.getLayerShape)
  • Exporting raw (unmasked) layers seems to be impossible as far as I know, please correct me if I am wrong. (we only have includeAncestorMasks option, but not any kind of pleaseDoNotIncludeMasksAtAll)
  • Getting pixmaps of bitmap masks is a totally untouched for now

Can you talk about this and tell me if it is possible to implement the missing parts and what priorities it has? I'd really like to implement all this using generator and avoid any kind of parsing PSD, because… you know :))

@joelrbrandt
Copy link
Contributor

@marekhrabe thanks for doing this spelunking.

@timothynoel could you weigh in a bit more on the two "unchecked" items in the comment above?

I think you've said that the first item (Exporting raw (unmasked) layers) might be possible now -- if it is, could you give us a few more details about what parameters to use? I don't see anything in the sendLayerThumbnailToNetworkClient KVLR documentation that makes it obvious how to do this. My best guess is that it might be something that can be set in the blendOptions of layerSettings?

I know you've said that getting pixmaps of bitmap masks is not supported at all right now. I also know you're looking for 15.3 tasks. Maybe this could be one? 😄

Thanks!

@joelrbrandt joelrbrandt added this to the PS 15.3 milestone Sep 21, 2014
@timothynoel
Copy link

Adding mask thumbnails: the machinery for creating these already exists inside Photoshop, I just need to add another key to sendLayerThumbnailToNetworkClient. But.. I'd really recommend we hook up greyscale/single channel pixmap support in Generator so we don't have to send it as ARGB.

As for disabling masks, and layerSettings, it's not for the faint of heart, and it's not super-well tested. It's very easy to get wrong, and you're code needs some knowledge of the layer stack beyond any single layer you're getting. I'd really recommend waiting for an actual direct API/param for this, and that would be easier to use, and faster internally. And it would be easier than trying to explain how to use layerSettings.

Anyway here's the lowdown: The easiest way to discover the format of layerSettings, is to make a comp, then get doc info on the document, and search for "layerSettings". Here's such a layerSettings dictionary with the vector/layer mask disabled. (in fact "layerSettings" is kind of an impromptu comp that's applied to the layer before the thumbnail is obtained)

  {
      "enabled": true,
      "imageMask": {
        "enabled": false
      },
      "vectorMask": {
        "offset": {
          "horizontal": 21,
          "vertical": -30
        },
        "enabled": false
      },
      "layerID": 2
    }

To use it, you need a "layerSettings" list of descriptors, one for each layer, each of which contain a "layerSettings" descriptor with the above format. If you're using the range format the list is lastLayer - firstLayer + 1 entries. In the single layerID, case, you need to know exactly how many layers are involved in the thumbnail (which makes it difficult to use, as you may be including children, or adjustors, or clipped layers) There's sample code using layerSettings, here: #120 (comment)

@marekhrabe
Copy link
Contributor Author

I'd really recommend we hook up greyscale/single channel pixmap support in Generator so we don't have to send it as ARGB.

I did additional support for 1 and 3-channel pixmaps for convert (as xmp.js already supports these three). Pull req in #268

I agree, the layerSettings way seems too complicated for this relatively simple task. Some API will be handy

@joelrbrandt
Copy link
Contributor

@timothynoel Thanks!

@marekhrabe I agree, we should make an API for this. We'll add it to our backlog, but of course PRs are welcome. (Thanks again for all your help thus far.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants