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...
Fontsize + viewport + trim
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Fontsize + viewport + trim
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
convert -background white -fill black -font Arial -pointsize 50 label:"I love you" -trim +repage result.gif
Re: Fontsize + viewport + trim
I use the following 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?
Code: Select all
code
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?
Last edited by gregory on 2012-04-12T16:46:05-07:00, edited 1 time in total.
Re: Fontsize + viewport + trim
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Fontsize + viewport + trim
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
See IM Examples, Text to Image Handling, Determining Font Metrics
http://www.imagemagick.org/Usage/text/#font_info
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Fontsize + viewport + trim
Okay, but how to solve the bug I mentioned above? I mean stroke blinking.
Re: Fontsize + viewport + trim
I solved the issue by using "-draw" instead of "label".
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Fontsize + viewport + trim
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/