Last active
December 11, 2015 14:28
-
-
Save mitu217/f098e0f096928a0f8581 to your computer and use it in GitHub Desktop.
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
def insert_message | |
img_file = "描画対象のファイルパス" | |
FileUtils.cp(img_file, img_file + ".org", {:preserve => true}) # 元画像退避 | |
img = Magick::ImageList.new(img_file) # 画像オブジェクト | |
draw = Magick::Draw.new # 描画オブジェクト | |
begin | |
draw.annotate(img, 0, 0, 0, -175, message) do | |
self.font = 'やさしさゴシックのファイルパス' # フォント | |
self.fill = 'black' # 文字色 | |
self.stroke = 'transparent' # 文字の縁色 | |
self.pointsize = 80 # フォントサイズ | |
self.gravity = Magick::CenterGravity # 画像の基点 | |
end | |
img.write(img_file) | |
rescue => e | |
exit 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment