Created
January 16, 2012 20:23
-
-
Save mdeiters/1622786 to your computer and use it in GitHub Desktop.
Adding RMagick image manipulation to a Rails 3 project
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
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' |
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
gem "rmagick", "2.12.0", :require => '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
match '/:username/endorsecount.png' => 'endorsements#show', :as => :user_endorsement, :count => true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment