将 ImageMagick CLI 翻译成 MiniMagick gem

Translate ImageMagick CLI into MiniMagick gem

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

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

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

哪个应该 return 像这样:

srgb(0%,68.0964%,93.8003%)

有什么想法吗?我很乐意直接粘贴该行,但我不确定 MiniMagick 是否是这样工作的。我也不确定 运行 在 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:u.p{0,0}]\n", "info:")
c.call

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