can not make font size adjust itself

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
dav22
Posts: 29
Joined: 2020-02-05T09:22:25-07:00
Authentication code: 1152

Re: can not make font size adjust itself

Post by dav22 »

thank you for your respond, you have been very helpful.
in the example above, I want the text stays on blue area and not go over image,
I don't want the text clipped, nor do I want to grow the area.
if I could control the font size to become smaller, that would be a good for me.
I know if I add font size, the I can control that but then I have to do it individually for every text I have ( text length are varied) and that is time consuming,

I understand that IM adjust the text size based on the width and the length of total area,
If there is an option that tell IM that size of font should be based on another new given size not total area, in that case IM will make it smaller font size, perhaps there are other way around.

thanks

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: can not make font size adjust itself

Post by snibgo »

You extend the image, make an image of the same size, and write over that. Instead, you can make an image that is just the size of the extension.

Windows BAT syntax:

Code: Select all

%IMG7%magick ^
  in.png  ^
  -resize 227 -gravity south -background lightblue ^
  -set option:MYSIZE %%wx%%[fx:504-h] ^
  -extent 0x504 ^
  -fill black -gravity northwest ^
  ( -size %%[MYSIZE] -background None ^
    caption:"This is sample text dsads   gfd gfd gf fd ggf gf gf gf gf g" ^
  ) ^
  -composite ^
  out.png
snibgo's IM pages: im.snibgo.com

dav22
Posts: 29
Joined: 2020-02-05T09:22:25-07:00
Authentication code: 1152

Re: can not make font size adjust itself

Post by dav22 »

thank you for your code, you have been very helpful indeed.
now it is working the way I wanted.

dav22
Posts: 29
Joined: 2020-02-05T09:22:25-07:00
Authentication code: 1152

Re: can not make font size adjust itself

Post by dav22 »

I have another problem that I had before, and IM here can not handle " ' " in the text, text having:
I’ve , it’s , They’re , couldn’t,
on my previous attempt pulling text from csv file, using code in windows batch file, you suggested to add these on top of batch file and it did work:
chcp 1251
setlocal enabledelayedexpansion

now I have tried these as well, but I am not sure where these line suppose to be,
I have put them on top of the code, and also tried in between ( ), but it does not work,
if these 2 lines help, where should I insert them?
thanks

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: can not make font size adjust itself

Post by snibgo »

"chcp" and "setlocal" are Windows shell commands. If you need them, type them as individual commands or separate lines in a script.
dav22 wrote:IM here can not handle " ' " in the text, text having:
I’ve , it’s , They’re , couldn’t,
Please show your command(s). Do you get an error message?
snibgo's IM pages: im.snibgo.com

dav22
Posts: 29
Joined: 2020-02-05T09:22:25-07:00
Authentication code: 1152

Re: can not make font size adjust itself

Post by dav22 »

thank you for respond;
yes I did put them on each line, but the the " ' " character just changed to something else,
I use chcp 65001 instead of chcp 1251, and problem solved,
thank you

Locked