admin管理员组文章数量:1379554
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.
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.
Share Improve this question asked Jun 5, 2016 at 12:11 Amin RezazadeAmin Rezazade 511 silver badge3 bronze badges 1- That is about the best way to do it if you need it done client side though I would question why not do the conversion just once on the server? – Blindman67 Commented Jun 5, 2016 at 13:04
1 Answer
Reset to default 7Browsers 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.
本文标签:
版权声明:本文标题:how can convert image cmyk to rgb mode in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744429594a2605873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论