Skip to content

Instantly share code, notes, and snippets.

@oropon
Created May 13, 2014 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oropon/bfef9248e0a0020bb67b to your computer and use it in GitHub Desktop.
Save oropon/bfef9248e0a0020bb67b to your computer and use it in GitHub Desktop.
annotate fname
require 'RMagick'
include Magick
id_min = 0
id_max = 10
def annotate_id img, id
fname = "Octcat_%03d.png" % id
text = Draw.new
text.font = '/System/Library/Fonts/Avenir Next.ttc'
text.pointsize = 100
text.gravity = CenterGravity
text.annotate(img, 0,0,0,0, fname) {
# 画像の色にかかわらず文字が読めるように縁取りする
self.stroke_width = 3
self.stroke = 'white'
self.fill = 'gray30'
}
img.write(fname)
end
img = ImageList.new 'octcat.png'
id_min.upto(id_max) do |i|
annotate_id img.copy, i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment