Example I have a image.
In my controller I example have @name = "Jon"
Now I want to create a new image as the image I got just with the name "Jon" in the middle of the image. I want to be able to specify the font-size, color and font-family that should be used and the position of the text.
What gem are able to do that?
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.new
gc.pointsize(50)
gc.text(30,70, "TEXT".center(14))
gc.draw(canvas)
canvas.write('tst.png')
I get the requirement, you can also go through. This should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With