Page 1 of 1

Fontsize + viewport + trim

Posted: 2012-04-11T08:37:12-07:00
by gregory
Hey guys,

I have a problem. I'm trying to create a picture using a user's text and font size. Unfortunately, I don't know the font size, font type and text length before creating a picture.
So I have to predefine somehow "-size" and "option:distort:viewport" options. But how? How to determine the width and height of the image I will need for this picture?
For example, I have text "I love you", font "Aactionman" and font size 50. What's next? I don't want to create a very big image since "-trim" option for some reason doesn't trim animations. If I would know the width and height of each letter in a font I would calculate image dimensions, but I don't know...

Re: Fontsize + viewport + trim

Posted: 2012-04-11T10:39:47-07:00
by fmw42
If you have the text, font and pointsize, then just do the following, (I don't have Aactionman font so you can use yours -- I just used Arial)

convert -background white -fill black -font Arial -pointsize 50 label:"I love you" -trim +repage result.gif

Re: Fontsize + viewport + trim

Posted: 2012-04-11T14:27:38-07:00
by gregory
I use the following code:

Code: Select all

code
(where animation.gif -- any gif animation)

As you can see the STROKE is blinking. If I delete "+repage" option everything is okay but image is not trimmed.

Could you please help me to create trimmed animation without using "-size" and "viewport" options?

Re: Fontsize + viewport + trim

Posted: 2012-04-11T19:36:56-07:00
by gregory
I would also appreciate if you help me to optimize this query. I assume third step can be combined with the first one but I don't know how to do it. I tried many variations with no success.

Re: Fontsize + viewport + trim

Posted: 2012-04-11T20:53:17-07:00
by anthony
More information about the text geometry used during the annotation of text can be gathered.

See IM Examples, Text to Image Handling, Determining Font Metrics
http://www.imagemagick.org/Usage/text/#font_info

Re: Fontsize + viewport + trim

Posted: 2012-04-12T06:53:02-07:00
by gregory
Okay, but how to solve the bug I mentioned above? I mean stroke blinking.

Re: Fontsize + viewport + trim

Posted: 2012-04-12T16:47:17-07:00
by gregory
I solved the issue by using "-draw" instead of "label".

Re: Fontsize + viewport + trim

Posted: 2012-04-13T06:42:00-07:00
by anthony
label: creates an image. Blinking means you created a GIF animation.

Instead of -draw, you can use -annotate.

For more examples see
Automatically Sized Annotated Text Canvases
http://www.imagemagick.org/Usage/text/#annotate_size

This goes on to adding color and even gradients to the text image.