[RESOLVED] Text rendering: label overflows

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Text rendering: label overflows

Post by qubodup »

fmw42 wrote:
It has to pick one or the other of W or Height to fit. You cannot fit both without one font size and without distorting the text in the other dimension.
Yes, that's what I wish to achieve. I am not trying to get this (GIMP MOCKUPS):
Image
Image
(eew) :)

I'm at ImageMagick 6.8.5-3 2013-04-27 Q16.

Code: Select all

convert -size 300x100 -gravity center label:"Test" label4.png
Image
---

Code: Select all

convert -size 100x300 -gravity center label:"Test:" label5.png
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text rendering: label overflows

Post by fmw42 »

You cannot best fit both dimensions, so one or the other will be used.

These two examples do not look correct
convert -size 200x20 label:"T_T" label7.png
Image

convert -size 200x20 label:"T____________________________________T" label8.png
Image

I do not know how label decides which dimension to best fit when specifying both W and H but no pointsize is specified. I suppose that it should check to see which one will not cut-off the text and not leave too much white space. In this sense, perhaps there is a bug or it needs an enhancement to test both ways and see which is best.


This is the best way to handle it, for now, until it is enhanced/fixed - pick one or the other dimension.
convert -size x20 label:"T_T" label7a.png
Image


convert -size x20 label:"T____________________________________T" label8a.png
Image
Last edited by fmw42 on 2013-05-10T10:49:02-07:00, edited 5 times in total.
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Text rendering: label overflows

Post by qubodup »

fmw42 wrote:You cannot best fit both dimensions, so one or the other will be used.
It seems to be impossible for me to convince you that I understand this?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text rendering: label overflows

Post by fmw42 »

No, on the contrary, you have convinced me that there is a bug or needs an enhancement according to the last examples you had me run.

Label should be able to tell which dimension to best fit so as to fill one dimension without over or under filling the other. The first two examples in my last post convinced me that you have found a problem.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text rendering: label overflows

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.5-7 Beta available by sometime tomorrow. Thanks.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Text rendering: label overflows

Post by fmw42 »

6.8.5-7 Beta

I am getting strange results from show:.

Compare these:

green letters, horizontal scaling and transparent on the right:
imb convert -size 200x100 label:"T_T" show:

looks fine:
imb convert -size 200x100 label:"T_T" x:
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Text rendering: label overflows

Post by qubodup »

My netbook with Arch Linux 32 bit had im 6.8.4-6 2013-04-03 Q16, so I tested some code on it.

Code: Select all

convert -size 300x100 -gravity center label:"Test" label4.png
Image
---

Code: Select all

convert -size 100x300 -gravity center label:"Test:" label5.png
Image

Then I upgraded to 6.8.5-3 2013-04-27 Q16.

Code: Select all

convert -size 300x100 -gravity center label:"Test" label4.png
Image
---

Code: Select all

convert -size 100x300 -gravity center label:"Test:" label5.png
Image
fmw42 wrote: imb convert -size 200x100 label:"T_T" show:
imb convert -size 200x100 label:"T_T" x:
What is the "imb " part? I recommend using the "code" bbcode tags for clarity when quoting code. Here's screenshots of what got displayed in 6.8.4-6:
show: Image
x: Image

And in 6.8.5-3 2013-04-27 Q16.

show: Image
x: Image

So I seem to be unable to reproduce what you described. (The font size changed though.) If nobody else can reproduce, perhaps you can post a screenshot of the displayed result.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text rendering: label overflows

Post by magick »

We can reproduce Fred's problem, its related to the show delegate. Fred, edit delegates.xml and change miff to png for the "show" delegate. In the mean-time we'll come up with a patch for the problem.

The "imb" command is just Fred's short cut for ImageMagick Beta.

Now the question is, given ImageMagick 6.8.5-7 Beta, does label: have any more bugs?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Text rendering: label overflows

Post by anthony »

Okay Quick tests show label: auto-size is now working

as is selecting a specific point size

But without any size or pointsize setting I am still getting a 'small' pointsize rather than the default of 12

Code: Select all

convert -version
Version: ImageMagick 6.8.5-7 2013-05-13 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP Modules
Delegates: autotrace bzlib djvu mpeg fftw fontconfig freetype gslib jng jp2 jpeg lcms lqr pango png ps rsvg tiff wmf x xml zlib

convert label:"what what what what what what what what" -print '%[label:pointsize]\n' -identify show:
10.71875
label:what what what what what what what what=>what what what what what what what what LABEL 232x15 232x15+0+0 16-bit sRGB 0.010u 0:00.019
and label image is longer than the expected font, producing extra space on the right. Second bug was not fixed
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Text rendering: label overflows

Post by qubodup »

In IM6 r12270 on Arch Linux 64bit, the spacing seems to work for me. See below for an explanation why the font family is different.

Code: Select all

./convert -size 200x20  label:T_T test.png
Image
---

Code: Select all

./convert -size 200x20  label:T____________________________________T testlong.png
Image

The font family seems strange, compared to the previous tests. This is probably because I did not install the compiled svn version but run from IM6/utilities/. Here are the messages I get: http://codepad.org/BEPzcvhy . It seems to be no issue if I specify a font.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Text rendering: label overflows

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.5-7 Beta available by sometime tomorrow. Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Text rendering: label overflows

Post by anthony »

I can not see any more problems. Thanks.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jdstruck
Posts: 3
Joined: 2013-05-21T06:24:41-07:00
Authentication code: 6789

Re: Text rendering: label overflows

Post by jdstruck »

Upon reading this thread, it would seem that this issue was resolved, however when I attempt to create a label, I am still seeing overflow, running 6.8.5-6 2013-05-07 Q16 on windows xp 32. If I set both height and width in the -size option, it will only "best fit" to height, and overflow to the sides. For my purposes, I need to create a label of an exact size, so just setting one of the variables is not an option. For now, I've been setting a -pointsize, as my typical label text is a set number of characters, however on occasion I will need to write more, and do not want to have to tweak the -pointsize every time. Any ideas?

Example:

Code: Select all

convert -size 225x150 -background white -fill black -font Arial -gravity center label:testing testing.jpg
Image
User avatar
qubodup
Posts: 31
Joined: 2009-10-07T13:11:41-07:00
Authentication code: 8675309

Re: Text rendering: label overflows

Post by qubodup »

jdstruck wrote:6.8.5-6
As far as I followed this thread, 6.8.5-7 still had issues.
jdstruck
Posts: 3
Joined: 2013-05-21T06:24:41-07:00
Authentication code: 6789

Re: Text rendering: label overflows

Post by jdstruck »

As far as I followed this thread, 6.8.5-7 still had issues.
Ahh sorry I did not read as carefully as I should have.
Post Reply