Real text size of added text?

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

User avatar
Peter2
XnThusiast
Posts: 1270
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Real text size of added text?

Post by Peter2 »

Hi to everybody

I use nconvert to add strings to images, but it seems that the text_size is smaller than expected.

Basic file: 250_250.png (attached)
Used command:

Code: Select all

nconvert.exe -keepfiledate -overwrite -out jpeg -q 100 -text_font "MS Shell Dlg 2" 35 -text_color 255 92 0 -text_flag top-left -text_pos 23 47 -text_rotation 0 -text "35 pix with NConvert" -o "C:\Temp\35pix.jpg"   "C:\Temp\250_250.png"
Result: 35pix.jpg (attached)

When I zoom to the text, I find only approx. 29pix high, including all over- and under-length. The "core" height is approx. 21 pix, so it is 1.7 times smaler than expected.

What's the reason for this?
You do not have the required permissions to view the files attached to this post.
XnView 2.50.2 German, Win 10
cday
XnThusiast
Posts: 3084
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Real text size of added text?

Post by cday »

The NConvert help file doesn't specify the units used in the -text option for text size, you are assuming possibly reasonably that the units are pixels?

Taking a look at XnConvert 1.90, the Text action has a Position tab on which a Units dropdown allows the selection of % or points. Exploring the effect of those options on the Preview image displayed, I have the impression that the units selected on that tab, perhaps surprisingly, also determine the size of the text displayed... :?:

You might like to check the text size on your test image above if you calculate the text size on the basis that the NConvert default text size unit is in fact points, that is 1/72 inch?
User avatar
Peter2
XnThusiast
Posts: 1270
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Re: Real text size of added text?

Post by Peter2 »

Thanks, cday
I see some question marks in your post, and I hope that Pierre can answer it soon. If not, I will try to find out.

BTW: The text in XnView - Plugin "Paint" uses the value for text_size as value for pixel (I hope I didn't mess up something)
XnView 2.50.2 German, Win 10
cday
XnThusiast
Posts: 3084
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Real text size of added text?

Post by cday »

If you check the file properties of your test file to find the canvas size in inches, I suspect that you will be able to confirm that NConvert text size uses points, 1/72 inch, which Pierre will hopefully indicate in the help file.
User avatar
Peter2
XnThusiast
Posts: 1270
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Re: Real text size of added text?

Post by Peter2 »

As usual, I reached the limit of knowledge ...

The idea is (example):
I have a photo, JPEG, 1200*1600 pix, landscape, no resolution. I want to add a test which height is 3% of the image height, so 1200 x 3% = 36 pix.
The advantage would be: every image has on "fullscreen" (on video or in Word document; the same for 1000 or 3000 pix) the same "visual size" of text

And what to do now? :shock:

When I use "points", e.g. every text is "3mm/(25.4mm/72) = 8.5 points", then they uses different percentage of place in different images.

Maybe both ideas are bad?
XnView 2.50.2 German, Win 10
cday
XnThusiast
Posts: 3084
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Real text size of added text?

Post by cday »

Peter2 wrote: Mon Apr 19, 2021 1:33 pm I have a photo, JPEG, 1200*1600 pix, landscape, no resolution. I want to add a test which height is 3% of the image height, so 1200 x 3% = 36 pix.
The advantage would be: every image has on "fullscreen" (on video or in Word document; the same for 1000 or 3000 pix) the same "visual size" of text
Your images will have a canvas size if you check their properties, from the canvas height in inches it should be possible to calculate the number of points (1/72 inch) that is the nearest value to 3% of the image height...

If your images have different canvas heights you have a problem, unless you can resize the canvas with a satisfactory result.

I am still assuming that NConvert reads the value entered as points, while awaiting any response from Pierre, or confirmation by examination of a test image which shouldn't be too difficult.

You probably really need NConvert to accept a text size in percent, something I have already requested be considered; that option is already available in Batch convert.
User avatar
Peter2
XnThusiast
Posts: 1270
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Re: Real text size of added text?

Post by Peter2 »

cday wrote: Mon Apr 19, 2021 1:46 pm Your images will have a canvas size if you check their properties, ....
I see it in the props via XnView, but how to get it from nconvert?
XnView 2.50.2 German, Win 10
cday
XnThusiast
Posts: 3084
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Real text size of added text?

Post by cday »

Peter2 wrote: Mon Apr 19, 2021 2:15 pm
cday wrote: Mon Apr 19, 2021 1:46 pm Your images will have a canvas size if you check their properties, ....
I see it in the props via XnView, but how to get it from nconvert?
If you can't use a value you can obtain yourself from the file properties, because the image heights vary too much, then you have a problem.

In principle the value can probably be obtained using the -info option, but you could only get that value into a variable that you can use with NConvert by using some scripting that is beyond my experience. You might get help from an online search (I think 'tokens' may be a relevant CMD keyword), or by posting on one of the general programming support sites. If you find the answer, please post it!

Assuming all the forgoing is actually correct and text height is set in points, I think you really need to ask Pierre nicely to add a 'percent of canvas height' text height option quickly... :D
cday
XnThusiast
Posts: 3084
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Real text size of added text?

Post by cday »

cday wrote: Mon Apr 19, 2021 2:43 pm Assuming all the forgoing is actually correct and text height is set in points...
Pierre has now indicated in the NConvert 7.80 Help file that text height is in fact set in pixels, not in points as I had suspected after some quick tests.
User avatar
Peter2
XnThusiast
Posts: 1270
Joined: Thu Nov 24, 2005 3:07 pm
Location: CH

Re: Real text size of added text?

Post by Peter2 »

Hi @cday
I saw that there is the new version, but this starts up my first posting. Why is such a big difference in height?
I will look in the next days ..

Edit: for me the most important text is here:

Code: Select all

size in pixels or % of height (ex: 40 or 10%)
"Percent" is the key value I was missing ...
XnView 2.50.2 German, Win 10