问题
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).
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:
Which should return something like this:
srgb(0%,68.0964%,93.8003%)
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.
回答1:
Solved it:
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
The trick was locating accurate profile paths and then entering "info:" as a separate second argument in the format method.
回答2:
I do not know RMagick, but just from reviewing the docs, you can see the equivalent commands at:
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)
来源:https://stackoverflow.com/questions/47026354/translate-imagemagick-cli-into-minimagick-gem