将ImageMagick CLI转换为MiniMagick gem

我终于想出了如何使用颜色配置文件和ImageMagick (使用ImageMagick 转换颜色(不是图像))将CMYK颜色转换为RGB值。

现在我正在努力使用MiniMagick将以下命令合并到Rails应用程序中:

 magick convert xc:"cmyk(255,0,0,0)" -profile USWebCoatedSWOP.icc -profile sRGB_IEC61966-2-1_black_scaled.icc -format "%[pixel:up{0,0}]\n" info: 

哪个应该返回这样的东西:

 srgb(0%,68.0964%,93.8003%) 

有任何想法吗? 我很乐意直接粘贴这条线,但我不确定这是不是MiniMagick工作方式。 我也不确定HerokuHeroku平台上运行Heroku

任何帮助,将不胜感激。

我不知道RMagick,但只是通过查看文档,您可以在以下位置查看等效命令:

 https://github.com/rmagick/rmagick (rmagick installation https://rmagick.github.io (documentation) https://rmagick.github.io/usage.html#reading (creating image from color) https://rmagick.github.io/image1.html#add_profile (add profile) https://rmagick.github.io/image3.html#pixel_color (getting color at coordinate) 

解决了它:

 c = MiniMagick::Tool::Convert.new c.xc("cmyk(255,0,0,0)") c.profile(File.open("lib/assets/USWebCoatedSWOP.icc").path) c.profile(File.open("lib/assets/sRGB_IEC61966-2-1_black_scaled.icc").path) c.format("%[pixel:up{0,0}]\n", "info:") c.call 

诀窍是找到准确的配置文件路径,然后在format方法中输入“info:”作为单独的第二个参数。