Created
January 29, 2013 06:53
-
-
Save neocanable/4662344 to your computer and use it in GitHub Desktop.
Rmagick 图片叠加图片
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rmagick' | |
include Magick | |
# customise user avatar or app icon | |
def merge_2_image(bg_path, icon_path) | |
background = Image.read(bg_path)[0] | |
icon = Image.read(icon_path)[0] | |
tmp = background.composite(icon, Magick::CenterGravity, 0, 0, Magick::OverCompositeOp) | |
tmp.write("/your/path") | |
end | |
merge_2_image('bg.png', 'icon.jpg') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Magick::CenterGravity is describe icon's location