问题
I have a problem:
Browsers do not support showing images in CMYK mode and the client see some really sharp and different colors in his uploaded image while the colors is alright.
solve this problem i think its a good idea to convert an CMYK image to a RGB mode image in client-side with using JavaScript language.
based on my search result about converting image in CMYK to RGB mode with using JavaScript, required image to be imported to a canvas and makes every color number in each pixel convert CMYK to RGB color number with using like this library ColorConverter and finally i have a canvas with RGB mode
this what i am thinking, now my question is if this solution is right ? and if there is any better way to do the job ? please give me your ideas.
回答1:
Browsers do not support showing images in CMYK mode
Showing CMYK images correctly wouldn't be possible as it is relative to the output device, and converting for simulated preview would need a locally calibrated and accurate ICC profile (or at least a high quality approximated profile if accuracy is not required).
You could simply convert each CMYK pixel into RGB, however, since RGB has a wider gamut than CMYK you might end up with a very bright looking result.
In my opinion the better approach is to implement a conversion setup at server side when uploading using ImageMagick or similar software which can take into account ICC profiles. This will allow you to keep the original CMYK file for download/print and a converted and approximated RGB version for preview purposes (you could f.ex. allow client to upload their output ICC for accurate preview).
In any case, the formula to convert CMYK data directly to RGB is:
var C, M, Y, K; // initialize with normalized values
Then
var r = 255 * (1 - C) * (1 - K);
var g = 255 * (1 - M) * (1 - K);
var b = 255 * (1 - Y) * (1 - K);
The alpha channel is set to fully opaque.
来源:https://stackoverflow.com/questions/37641733/how-can-convert-image-cmyk-to-rgb-mode-in-javascript