Good friends of stackoverflow, I am here today for guidance regarding image processing/manipulation using Ruby in a Rails environment. I'm creating on-the-fly dynamic banner ads that will feature mostly (if not completely) text. It's fairly simple with just a line or two, but I'd like the option to adjust font, text color, text size, etc.
What libraries do you recommend for this sort of task?
I've read up in rMagick a little bit and I see a lot of complaints about memory issues and lack of text rendering features. I'm not seeing many alternative active projects.
Thanks!
Edit: I got a chance to mess around with RMagick and while it's library is full featured, it seriously lacks in the text department. One feature I'm unable to use is non-breaking spaces. I'm printing a phone number in my text and it really doesn't make sense to have the area code on a different line than the rest of the number.
I'm choosing RMagick as the best solution for now, because it's full-featured and actively developed, but it is by no means a good solution.
I wrote something like the following:
require 'rubygems'
require 'RMagick'
include Magick
image = Image.new(50, 50) {
self.background_color = "white"
}
text = Draw.new
text.annotate(image, 0,0,0,40, 'Named Colors') {
self.fill = 'black'
self.pointsize = 32
}
image.write("image.png")
Which should be easy enough to follow. Also have a look at the documentation. Whilst it's not quite laid out to perfection, it's pretty much all there.
You can farm out your image processing needs to the command-line version of ImageMagick instead of using the the rMagick Ruby bindings.
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