本文介绍了如何在javascript中将cmyk转换为rgb模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个问题:浏览器不支持在CMYK模式下显示图片,客户端在上传的图片中看到一些非常尖锐和不同的颜色,好吧。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.解决这个问题,我认为这是一个好主意,使用JavaScript语言将CMYK图像转换为客户端的RGB模式图像。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.基于我的搜索结果,使用JavaScript将CMYK中的图像转换为RGB模式,将所需的图像导入到画布中,并使每个像素中的每个颜色数字将CMYK转换为RGB颜色数使用像这个库 ColorConverter ,最后我有一个有RGB模式的画布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.推荐答案你可以简单地将每个CMYK像素转换为RGB, ,有以下几个问题:You could simply covert each CMYK pixel into a RGB, however, there are several issues with this: RGB有一个更宽的色域,并且它需要 ICC配置文件以转换为正确的RGB值,否则可能会得到非常明亮的结果。 您需要通过JavaScript实现ICC处理(存在 ICC parser ,但它不会通过 LAB 或 XYZRGB has a wider gamut than CMYK and it would require a ICC profile to covert to the correct RGB values, or else you might end up with a very bright looking result.You would need to implement ICC handling via JavaScript (there exist a ICC parser but it won't do the actual conversion for you via the LAB or XYZ color-spaces).It would be relative expensive to convert each time (especially with larger images meant for print).在我看来,更好的方法是在上传时使用实现转换过程ImageMagick 或可以考虑ICC配置文件的类似软件。In my opinion the better approach is to implement a conversion process at upload using ImageMagick or similar software which can take into account an ICC profile. This will allow you to keep the original CMYK for download/print and a properly converted RGB version for preview.在任何情况下,将CMYK数据转换为RGB的公式都是可用于下载/打印的正确转换的RGB版本。 :In any case, the formula to convert CMYK data to RGB is:var C, M, Y, K;// assumed to be initialized with proper normalized values herevar r = 255 * (1 - C) * (1 - K);var g = 255 * (1 - M) * (1 - K);var b = 255 * (1 - Y) * (1 - K); Alpha通道设置为完全不透明。The alpha channel is set to fully opaque. 这篇关于如何在javascript中将cmyk转换为rgb模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 13:46
查看更多