使用RMagick将CMYK图像正确转换为RGB [英] Properly converting a CMYK image to RGB with RMagick

查看:157
本文介绍了使用RMagick将CMYK图像正确转换为RGB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用下面的颜色转换

I have been using the below to do a color conversion

    if @image.colorspace == Magick::CMYKColorspace
      # @image.colorspace #=> CMYKColorspace=12
      @image.colorspace = Magick::RGBColorspace
      @image = @image.negate
    end

大约有效,但颜色亮度不合适。我需要否定图像的事实留下了非常难闻的气味。

It works, approximately, but the color luminosity is off. The fact that I need to negate the image leaves a very bad smell.

文档提到使用color_profiles,但除此之外我找不到太多。

The documentation mentions using color_profiles, but beyond that I can not find much.

我正在尝试

@image = @image.quantize(16777216, Magick::RGBColorspace)

颜色更好,但仍然关闭。

And the colors are better, but still off.

推荐答案

谢谢Pekka,你给了我答案(+1)。

Thanks Pekka, you tipped me off to the answer (+1).

你必须拥有ImageMagick已安装小色彩管理系统(LCMS)。如果使用安装程序或包,可能已经是这种情况。但我是从源头编译的。它就像从源代码安装LCMS并重建ImageMagick( ./ configure; make; make install )一样简单。

You must have ImageMagick compiled with the Little Color Management System (LCMS) installed. This may already be the case if an installer or package was used. But I was compiling from source. It was as simple as installing LCMS from source and rebuilding ImageMagick (./configure; make; make install).

在ImageMagick中,下面可以很好地重现准确的颜色:

In ImageMagick the below works well to reproduce accurate color:

转换FILENAME -profile /PATH_TO_PROFILE/sRGB.icm OUT.jpg

所以在RMagick我使用以下内容:

So in RMagick I use the below:

if @image.colorspace == Magick::CMYKColorspace
   # Adjust the path as necessary
   @image.color_profile ="/usr/local/share/ImageMagick-6.5.4/config/sRGB.icm"
end

@image.write("out.jpg") { self.quality = 85 }

这篇关于使用RMagick将CMYK图像正确转换为RGB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆