Using rmagick to colorize an image, such as in Photoshop

So, I have this basic image:

enter image description here

And in Photoshop, I make a layer with the main color layer with rgb colors:

r: 244, g: 93, b: 0

This gives me an amazingly bright:

enter image description here

What I'm trying to do is colorize the same image in rmagick, so if I do the following coloring:

  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

This gives me this really washed orange image:

enter image description here

My questions are: how do I color this image using these rgb options in imagemagick / rmagick to get the same vibrant color that I got in Photoshop.

Thank.

+4
source share
2 answers

, , - :

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')
+3

Mark Setchell (Windows) ...

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

rmagick... ftp://belagro.com/Redmine/ruby/lib/ruby/gems/1.8/gems/rmagick-2.12.0/doc/colorize.rb.html

, , ( )?

# load the greyscale image
img = Magick::Image.read('greyscale.png').first
# Colorize with a 100% blend of the orange color
colorized = img.colorize(1, 1, 1, '#A50026')
# save the colour image
colorized.write('colour.png')

- rgb(244,93,0)= #A50026

+2

All Articles