webtoon / psd

Fast zero-dependency PSD parser for the web and Node.js
https://webtoon.github.io/psd
MIT License
1.21k stars 55 forks source link

ICC profile #46

Closed scoiatael closed 2 years ago

scoiatael commented 2 years ago

One of features available in psd-tools is ICC profile handling.

This is done by extracting relevant tag and then converting image data after extraction.

This in turns uses Python bindings for littlecms (https://pypi.org/project/littlecms/). In our case this won't fly - closest thing I was able to find are low-level binding based on emscripten.

So the questions are:

pastelmind commented 2 years ago

ICC color profiles are far beyond our interests--but if you can provide a PR, please go ahead! I can guarantee that no one (including myself) will be working on this for the foreseeable future.

That said, one of our goals is keeping the dependency count at zero. I also agree that having our own bindings would be better than importing another library. Either approach (full conversion VS simply exposing the raw data) is fine.

P. S. I am unfamiliar with ICC color profiles and color management. Could you briefly explain the value of this feature for me?

scoiatael commented 2 years ago

First of all - I'm also not an expert. What I know is that OpenDesign should support this feature: around 6% of designs on our platform (or, at least 6% of designs in sample I use for testing) have non-standard ICC profile: adobeRGB and U.S. Web Coated (SWOP) v2 being the most common.

For these designs exported images are wrong - colors are off (for some less, for others more). For some reason I can't get it to work with open-source version of psd-tools, so here's comparison from our internal fork:

exported from Photoshop:

exported

psd-tools (internal):

gitlab-psd-tools

webtoon/psd:

webtoon


Main reason that SWOP is so off is that it's the only CMYK color mode in this comparison.

Also looks like there is a proposal to have colorSpace in ImageData.

scoiatael commented 2 years ago

Did some testing and looks like minimal size added by color conversion via Little-CMS would be around ~400kB:

 384K ┌── lcms.js 

So it looks like the best course is to simply expose information on color profile and let users take care of conversion.

Code and more compilation options are here.