Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用CMYK创建Rmagick/ImageMagick图像_Ruby On Rails_Image Processing_Imagemagick_Rmagick - Fatal编程技术网

Ruby on rails 使用CMYK创建Rmagick/ImageMagick图像

Ruby on rails 使用CMYK创建Rmagick/ImageMagick图像,ruby-on-rails,image-processing,imagemagick,rmagick,Ruby On Rails,Image Processing,Imagemagick,Rmagick,基本上,我是图像处理新手,不知道是否有人能给我一个线索 我不想使用imagemagick和rmagick从头开始创建一个图像(比方说一个代码条图像)用于打印目的。我知道如何将颜色空间设置为CMYK(最适合打印)以及如何包含颜色配置文件。但每当我试图画这些条时,CMYK的颜色就会出现错误 这基本上就是我正在做的: bcolor = "cmyk(0%, 100%, 100%, 0%)" # background color Red fcolor = "cmyk(0%, 0%, 0%, 10

基本上,我是图像处理新手,不知道是否有人能给我一个线索

我不想使用imagemagick和rmagick从头开始创建一个图像(比方说一个代码条图像)用于打印目的。我知道如何将颜色空间设置为CMYK(最适合打印)以及如何包含颜色配置文件。但每当我试图画这些条时,CMYK的颜色就会出现错误

这基本上就是我正在做的:

bcolor  =  "cmyk(0%, 100%, 100%, 0%)"  # background color Red
fcolor  =  "cmyk(0%, 0%, 0%, 100%)"    # foreground color Black

#Creating the Canvas
canvas = Magick::Image.new(100, 100){
  self.background_color = bcolor
}

canvas.add_profile("#{Rails.root}/my.icc")
canvas.colorspace=Magick::CMYKColorspace # Set CMYK color space

# Class to draw the bars
bars = Magick::Draw.new
bars.fill(fcolor) # Setting the bars color

# Lets draw only 2 bars
bars.rectangle(10, 0, 20, 100)
bars.rectangle(30, 0, 35, 100)

bars.draw(canvas)
blob = canvas.to_blob {self.format = 'jpg'}

File.open("test.jpg", 'w') do |f|
  f.write blob
end
即使正确生成背景色(红色),也会以不同的颜色绘制条形图

我做了一些研究,发现如果我理解正确的话,Rmagick的Draw类不支持cmyk,而是使用sRGB进行渲染,因为imagemagick中的
draw
就是这样工作的

是否有任何方法可以使用此工具在CMYK中绘制此条?可能是
Draw
类的解决方法?还是用CMYK画条的另一种方法

提前谢谢

还有

ImageMagick版本:6.8.0-10 2013-04-10

Rmagick:2.13.2

ImageMagick的绘图引擎仅在sRGB颜色空间中工作。因此,解决问题的唯一方法可能是使用sRGB,然后将整个图像转换为CMYK

中介绍了如何将sRGB转换为CMYK