Skip to content

Instantly share code, notes, and snippets.

@mitu217
Last active December 11, 2015 14:28
Show Gist options
  • Save mitu217/f098e0f096928a0f8581 to your computer and use it in GitHub Desktop.
Save mitu217/f098e0f096928a0f8581 to your computer and use it in GitHub Desktop.
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