PSD.JS Parsing the color of a text layer

倖福魔咒の 提交于 2019-12-13 03:01:40

问题


I am using PSD.JS (a photoshop PSD file parser for NodeJS and browsers) to parse a few PSD files. When the parser extracts the information for a text layer, the color information is returned as an array.

e.g: colors": [ [ 102, 0, 255, 0, 255 ], [ 102, 0, 255, 0, 255 ] ]

But the array contains 5 values instead of 3 for RGB or 4 for CMYK.

Please can somebody help me understand why the color is represented with 5 values?

And is there a way to convert this into RGB equivalent?

I am pretty sure this is not an issue with PSD.JS but an implementation detail.


回答1:


PSD.js mainainer here.

After some digging in the source code i discovered that this image channel parsing follows the js canvas convention of pixel channeling as discribed here.

as the doc states:

Parse the image data. 
The resulting image data will be formatted to match the Javascript Canvas color format.
 e.g. [R, G, B, A, R, G, B, A].

So this has nothing to do with the psd file format or the image in question, it is simply because we parse it this way so you can conveniently apply the buffer to a canvas.



来源:https://stackoverflow.com/questions/47473588/psd-js-parsing-the-color-of-a-text-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!