ruby-on-railsrubycolorsimagemagickcolor-profile

Converting colors (not images) with ImageMagick


More specifically, I'd like to accurately convert a CMYK value (probably from the ISO Coated v2 space) to an RGB value (probably from the sRGB space) on the Ruby platform (probably using ICC profiles).

ImageMagick seemed like a good place to start, but I've also heard that LittleCMS might have been ported/wrapped to work with Ruby.

Once again, I'm looking to convert single colors, NOT image files. Any ideas?


Solution

  • In ImageMagick, you can do the following:

    convert xc:"cmyk(0,255,255,0)" -colorspace sRGB -format "%[pixel:u.p{0,0}]\n" info:
    red
    
    convert xc:"cmyk(0,255,255,0)" -profile /Users/fred/images/profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/profiles/sRGB.icc -format "%[pixel:u.p{0,0}]\n" info:
    srgb(93%,11%,14%)