skip to Main Content

So I have this base image:

enter image description here

And in photoshop I do a basic layer color overlay, with the rgb colors:

r: 244, g: 93, b: 0

This gives me the amazingly vibrant:

enter image description here

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

  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

It gives me this really washed out orange image:

enter image description here

My questions is, how do I colorize this image with those rgb params in imagemagick / rmagick, to get the same vibrant color that I got in photoshop.

Thanks.

2

Answers


  1. At the commandline, I think you want something like this:

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

    enter image description here

    So, with the +clone I am creating another layer the same size as your image and entirely filling it 100% with your orange colour and then composing it over your image with the -composite to blend the opacity and colour.

    I really don’t speak Ruby, but I think it will be along these lines:

    #!/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')
    
    Login or Signup to reply.
  2. Mark Setchell’s command line works for me (Windows), with slight modifications…

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

    Found this link on recolouring with rmagick…
    ftp://belagro.com/Redmine/ruby/lib/ruby/gems/1.8/gems/rmagick-2.12.0/doc/colorize.rb.html

    Based on the code in the above link, with the greyscale conversion removed, does the example below work (I don’t have ruby)?

    # 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')
    

    Used a colour picker to get the hex of your orange colour – rgb(244,93,0) = #A50026

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search