Reputation: 1721
What I am looking for is some sample code, preferably Ruby on Rails, on how to dynamically create an image containing text in a specific font.
Basically I want to create a URL like this:
/api/text_as_image?font=futura&text=foo
And have it return an image containing the text "foo" in the font "futura". I know this can be done with ImageMagick, just can't seem to figure it out. Any help is appreciated.
Upvotes: 4
Views: 2955
Reputation: 51
Check out the magick_title gem:
Here's the basic usage:
# this could come from your form
params[:magick_title] = { :font_size => 24, :color => '#ff0000' }
# Then in your controller
MagickTitle.say("Hello!", params[:magick_image]).to_html
Upvotes: 5