Skip to content

Instantly share code, notes, and snippets.

@derencius
Created November 8, 2012 21:04
Show Gist options
  • Save derencius/4041592 to your computer and use it in GitHub Desktop.
Save derencius/4041592 to your computer and use it in GitHub Desktop.
MiniMagick & ImageMagick - Level Colors and Composite
require 'rubygems'
require 'mini_magick'
color = '#103afc'
img = MiniMagick::Image.open("letter_x.png")
img.combine_options do |c|
c.add_command( 'level-colors')
c.+ "#{color},"
end
img.write("output1.png")
com = MiniMagick::Image.open('fruits.png')
com.combine_options do |c|
c.add_command( 'level-colors')
c.+ "white,#{color}"
end
result = img.composite(com) do |c|
c.geometry '-0-10'
c.gravity 'North'
end
result.write("output.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment