Basically I'm new to Image processing and wondering if someone could give me a lead here.
I wan't to create an image (lets say a code bar image) from scratch using imagemagick and rmagick for printing purposes. I know how to set the ColorSpace to CMYK ( which is the best for printing) and how to include the color profile file. But whenever I try to draw the bars, CMYK colors come out wrong.
This is basically what I'm doing:
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
Even when background color (red) is generated correctly, bars are drawn in a different color.
I made some research and found, If I understood correctly, that Draw class from Rmagick won't support cmyk, instead it uses sRGB for rendering. http://www.multipole.org/discourse-server/viewtopic.php?t=11254&p=36074 , because draw
from imagemagick works that way.
Is there any way to draw this bars in CMYK using this tools? Probably a workaround for the Draw
class? Or another way to draw the bars using CMYK?
Thanks in advance
Also...
ImageMagick Version: 6.8.0-10 2013-04-10
Rmagick: 2.13.2