image - 使用 rmagick 像在 Photoshop 中一样为图像着色

标签 image colors imagemagick rmagick colorize

所以我有这个基本图像:

enter image description here

在 photoshop 中,我使用 rgb 颜色进行基本图层颜色叠加:

r: 244, g: 93, b: 0

这给了我惊人的活力:

enter image description here

我想要做的是在 rmagick 中为相同的图像着色,所以如果我执行以下着色:

  img = Magick::Image.read('brush.png').first
  img = img.colorize(100, 100, 100, Magick::Pixel.new(244, 93, 0, 1))
  img.format = 'png'
  img.to_blob

它给了我这个真正褪色的橙色图像:

enter image description here

我的问题是,如何使用 imagemagick/rmagick 中的那些 rgb 参数为该图像着色,以获得与我在 photoshop 中获得的相同鲜艳的颜色。

谢谢。

最佳答案

在命令行,我想你想要这样的东西:

convert brush.png \( +clone -fill "rgb(244,93,0)" -colorize 100% \) -compose colorize  -composite out.png

enter image description here

因此,使用 +clone我正在创建另一个与您的图像大小相同的图层,并用您的橙色完全填充它 100%,然后使用 -composite 将其组合在您的图像上。混合不透明度和颜色。

我真的不会说 Ruby,但我认为应该是这样的:
#!/usr/bin/ruby

require 'RMagick'
include Magick
infile=ARGV[0]
img=Magick::Image.read(infile).first
w=img.columns
h=img.rows
ovl=Image.new(w,h){self.background_color=Magick::Pixel.new(244*256,93*256,0)}
img.composite!(ovl,0,0,Magick::ColorizeCompositeOp)
img.write('result.png')

关于image - 使用 rmagick 像在 Photoshop 中一样为图像着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29452376/

相关文章:

image-processing - 用高度替换区域的颜色 imagemagick

python - 使用 Wand/ImageMagick Python 将文本字符串渲染为图像以计算长度

ffmpeg - 将带有 alpha channel 的 FLV 视频转换为具有透明度的 PNG

php - 上传图片,创建缩略图然后保存

python - 使用 opencv Python 删除图像的背景

css - Materialise:向调色板添加颜色?

java - 随机选择 4 种颜色?

javascript - 不知道图片类型时的Base64图片SRC

image - 为什么 XAML 图像源属性包含 "/MyApp;component"?

r - 从颜色中删除线条并填充图例