将ImageMagick CLI转换为MiniMagick gem [英] Translate ImageMagick CLI into MiniMagick gem
问题描述
我终于想出如何使用颜色配置文件和<$ c将 CMYK
颜色转换为 RGB
值$ c> ImageMagick (使用ImageMagick转换颜色(不是图像) )。
I finally figured out how to convert a CMYK
color into an RGB
value using color profiles and ImageMagick
(Converting colors (not images) with ImageMagick).
现在我正在努力将以下命令合并到 Rails
应用程序中 MiniMagick
:
Now I'm struggling to incorporate the following command into a Rails
app using 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:
哪个应返回如下内容:
srgb(0%,68.0964%,93.8003%)
任何想法?我很乐意直接粘贴该行,但我不确定这是 MiniMagick
的工作方式。我也不确定这将在 Heroku
平台上运行得多好。
Any ideas? I would be happy to just paste the line in directly but I'm not sure if that's how MiniMagick
works. I'm also not sure how well this will run on the Heroku
platform.
任何帮助都将不胜感激。
Any help would be appreciated.
推荐答案
解决它:
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
诀窍是找到准确的配置文件路径,然后在格式
方法中输入info:作为单独的第二个参数。
The trick was locating accurate profile paths and then entering "info:" as a separate second argument in the format
method.
这篇关于将ImageMagick CLI转换为MiniMagick gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!