Skip to content

Instantly share code, notes, and snippets.

@mdeiters
Created January 16, 2012 19:30
Show Gist options
  • Save mdeiters/1622524 to your computer and use it in GitHub Desktop.
Save mdeiters/1622524 to your computer and use it in GitHub Desktop.
Adding text to a PNG in RMagick
image = Magick::Image.read(image_path).first
gc = Magick::Draw.new
gc.stroke('transparent')
gc.fill('#202123')
gc.pointsize('11')
gc.font_family = "helvetica"
gc.font_weight = Magick::BoldWeight
gc.font_style = Magick::NormalStyle
gc.text(x = 83, y = 14, text = user.endorsements.size.to_s)
gc.draw(image)
send_data image.to_blob, :type => 'image/png', :disposition => 'inline'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment