Hi,
I am trying to fill a set area with text, the pointsize needs to be automatic so that if I dont write much it will still fill the area the same as if I was to write loads.
The area needs to be multi-line too.
I know that by using "caption" I can set the font size, and the width and imagemagick will produce an image with a variable height - but I want to fix the height and width and let imagemagick produce an image with a variable text size.
Any ideas ?
Thanks,
Tom
Fill an area with text
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
You are asking too much freedon for IM to work out what you want.
To have a fixed area, with caption like multi-line freedom, requires a considerable amount of trial and error to figure out a pointsize that will fill such area.
It could be done, but will require a higher level of wrapping around caption that is currently programmed.
Cristy could add it to a to do list however, but there are currently other things needing to be done.
To have a fixed area, with caption like multi-line freedom, requires a considerable amount of trial and error to figure out a pointsize that will fill such area.
It could be done, but will require a higher level of wrapping around caption that is currently programmed.
Cristy could add it to a to do list however, but there are currently other things needing to be done.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Thanks,
I thought that may be the case - I've got it doing almost what I want using the command -
convert -background black -fill white -font tahomabd.TTF -gravity center -size 500x500+0+0 label:'I can type anything \n including new lines\n and another' -bordercolor black -border 20x20 image.png
This seems to give fairly close to what I want, and instead of just allowing the user to type in a single text box I am using a multi-line box.
Thanks,
Tom
I thought that may be the case - I've got it doing almost what I want using the command -
convert -background black -fill white -font tahomabd.TTF -gravity center -size 500x500+0+0 label:'I can type anything \n including new lines\n and another' -bordercolor black -border 20x20 image.png
This seems to give fairly close to what I want, and instead of just allowing the user to type in a single text box I am using a multi-line box.
Thanks,
Tom
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
I have been thinging of your request, and I came to the conclusion that I was wrong. IM could probably do a 'best fill area given' type of "caption:" when pointsize is not provided, however BOTH width and height must be provided (unlike "label:" which only needs one or the other).
To summerise...
http://www.cit.gu.edu.au/~anthony/graph ... e/#caption
The "caption:" image creation operator, given a text "-pointsize" and "-size" width of an area to be filled, can automatically add newlines as appropriate.
Given both the width and height ("-size") of the area to fill. Adjust the fonts "-pointsize" until the text just filles the whole space without overflowing.
That is start a large "-pointsize", and run "caption:" to add new lines to the text. If the text overflows the area to fill (width or bottom), try a smaller pointsize, if it fits, increase the pointsize untill it just fits the "-size" area requested.
Note if no "-pointsize" is given and BOTH width and height "-size" attributes are missing then "caption:" should error, as it currently does if missing width. that is, width is always required, but height or pointsize can be made interchangable.
To summerise...
http://www.cit.gu.edu.au/~anthony/graph ... e/#caption
The "caption:" image creation operator, given a text "-pointsize" and "-size" width of an area to be filled, can automatically add newlines as appropriate.
Given both the width and height ("-size") of the area to fill. Adjust the fonts "-pointsize" until the text just filles the whole space without overflowing.
That is start a large "-pointsize", and run "caption:" to add new lines to the text. If the text overflows the area to fill (width or bottom), try a smaller pointsize, if it fits, increase the pointsize untill it just fits the "-size" area requested.
Note if no "-pointsize" is given and BOTH width and height "-size" attributes are missing then "caption:" should error, as it currently does if missing width. that is, width is always required, but height or pointsize can be made interchangable.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Hi,
I think I must have an older version of IM as mine wont do that - if you set the height and width it errors until you set the pointsize, you can leave out the height and set width and pointsize, but it wont let me leave out the pointsize.
I have got round the problem now by allowing the user to type into a multiline text box (lines are seperated by \n), then using label instead of caption.
This is probably actually better for my needs as it allows the user to have a bit of control about how the text is layed out on the image.
Thanks,
Tom
I think I must have an older version of IM as mine wont do that - if you set the height and width it errors until you set the pointsize, you can leave out the height and set width and pointsize, but it wont let me leave out the pointsize.
I have got round the problem now by allowing the user to type into a multiline text box (lines are seperated by \n), then using label instead of caption.
This is probably actually better for my needs as it allows the user to have a bit of control about how the text is layed out on the image.
Thanks,
Tom
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Mine is only just starting to do that, but then it is the beta release.
It is currently going through beta testing and debugging.
Wait a week for 6.3.2 and you also will have it.
See IM Examples, Cpations, for the current testing and examples
http://www.cit.gu.edu.au/~anthony/graph ... t/#caption
It is currently going through beta testing and debugging.
Wait a week for 6.3.2 and you also will have it.
See IM Examples, Cpations, for the current testing and examples
http://www.cit.gu.edu.au/~anthony/graph ... t/#caption
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/