Page 2 of 2

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-06T12:44:03-07:00
by kevinleesmith
Aha - bingo - Now I understand as %1 etc is using on BAT scripts for parameter passing. I remove the double % and its fine now.
Many many thanks.

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T06:27:34-07:00
by kevinleesmith
Thanks - that did the trick - i did send this message yesterday but I just came here to post another comment and my comment thanking you from yesterday is not here!!! (second time that happened)

Anyway,

Everything looks fine apart from a couple of things that are not quite right in relation to the size of the text.

The good
This one has a lot of text and is sized correctly to fill: http://www.pragmaticea.com/PF2/componen ... 000276.png
This one has a small amount of text and is sized correctly to fill: http://www.pragmaticea.com/PF2/componen ... 000526.png

The bad (maybe it sizes the text and stops when it cannot go bigger without a word fitting on 1 line?
http://www.pragmaticea.com/PF2/componen ... 000470.png

The ugly
You can see all images I have produced and the resulting variation in success/failure of the text to be scaled to fit here (warning - this html will try to load 300+ images): www.peaf.com/images/temp.htm

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T06:43:01-07:00
by snibgo
wrote:The bad (maybe it sizes the text and stops when it cannot go bigger without a word fitting on 1 line?
http://www.pragmaticea.com/PF2/componen ... 000470.png
What is bad about that? The text cannot be larger, as you say. Would you prefer it smaller?

IM records the pointsize it used in property "caption:pointsize:", so you can re-run with an explicit pointsize that is, say, 80% of the recorded value.

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T06:54:12-07:00
by kevinleesmith
Yes I figured out what it was doing while I was writing that, which, as you say, is reasonable.

Maybe an enhacement request then - for IM to split words and insert a hyphen to break words so it can maximise the text size within an area?

I'm not griping though I already donated $50 to them.

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T07:11:18-07:00
by snibgo
Hyphenation would be a useful enhancement. However, it requires a dictionary of words marked with all possible hyphenation points, and one dictionary is required per language, and we would need to tell IM what language is being used.

For that, more specialist typography software might be needed.

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T09:05:25-07:00
by kevinleesmith
True.

One last question to finish this post - Can I change the blue background to a diagonal gradient fill from dark blue to lighter blue? I've looked through the docs and found https://imagemagick.org/script/gradient.php but not sure how to apply that to my blue box

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T09:49:41-07:00
by snibgo
I would do that by writing the text with "-background None", which means transparent. Clone this, and make that image the gradient. Composite the text image over the gradient image. Then append that to the input image.

Code: Select all

%IMG7%magick ^
  testing2.png ^
  -size 200x%%[fx:h] ^
  -background None ^
  caption:"This is some text that could be of any length which should be made as big as possible to fill the box" ^
  ( +clone ^
    -sparse-color bilinear "0,0,#00f,%%[fx:w-1],%%[fx:h-1],#88f" ^
  ) ^
  ( -clone 1,2 ^
    -compose DstOver -composite ^
  ) ^
  -delete 1,2 ^
  +append ^
  capt-right2.png

Re: Add Auto sized text to rectangle area of image

Posted: 2018-12-07T12:04:48-07:00
by kevinleesmith
Coll - many thanks. Its really a programming environment in its own right. Could be useful to have an IDE that churns out the code required.