[Rails] Re: Alternatives to rmagick?
On 21 Oct 2009, at 14:20, Victor Martin wrote:
Is there any real alternative to RMagick? I need to compose some texts
to an image, so I don't really need anything really complex.
ImageMagick through the command line?
Sometimes you need to add textual annotations to an image. For example, imagine that your company has a standard business card image and wants to put each employee's details onto the card before sending it to the printer. Another example is generating presentation certificates for users who pass an online course on your Web site.
Let's say you start with this image:
Figure 6. A picture from Floriade 2002
You could annotate the image with some identifying information using the following command line:
# convert -font helvetica -fill white -pointsize 36 \
-draw 'text 10,50 "Floriade 2002, Canberra, Australia"' \
floriade.jpg comment.jpg
And here is the result:
Figure 7. An annotated picture from Floriade 2002
This is by far the most complex
convert
command line I have shown so far in the article, so I'll take some time to explain it.-font helvetica
sets the annotation's font to Helvetica. It is possible here to specify a path to a font file as well. This example badges the image so it can't be reused by other Web sites without permission, but it does so using a font that is in a non-standard location:# convert -font fonts/1900805.ttf -fill white -pointsize 36 \
-draw 'text 10,475 "stillhq.com"' \
floriade.jpg stillhq.jpg
This is the result:
Figure 8. A badged image
-fill white
fills the letters with white instead of the standard black.-pointsize 36
specifies the size of the letters, in points. There are 72 points to an inch.-draw 'text 10,50 "..."'
is a set of drawing commands, in this case to move to the position 10, 50 and then draw the text in the double quotes. The single quotes are used because the double quotes are needed within the drawing command if more than one word is to be drawn, and you cannot have double quotes within double quotes.Best regards
Peter De Berdt
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home