simple text to image solution for rails simple text to image solution for rails heroku heroku

simple text to image solution for rails


A basic rmagick solution isn't that bad, 6 lines. The following gives you a yellow rectangle with TEXT in the center. You can experiment with the font and point size. The center call is there because I thought it looked better in the middle.

require 'RMagick'canvas = Magick::Image.new(300, 100){self.background_color = 'yellow'}gc = Magick::Draw.newgc.pointsize(50)gc.text(30,70, "TEXT".center(14))gc.draw(canvas)canvas.write('tst.png')


Might be worth looking into libgd2 (the gd2 gem) which is lighter weight than rmagick and ImageMagick. Not sure if they've implemented text functions in the gem, but it's not difficult to extend to call other libgd2 functions.