These comments all apply to Slackware GNU/Linux 14.0. I don't know
if this bug manifests in any other OS or OS version.
The following command worked sort of properly in imagemagick-6.7.7
convert -background lightblue -fill black -size 210x210 \
-gravity center -interline-spacing 0 -extent +0-10 \
-quality 60 label:"HP\n4" x.jpg
ie it produced an image with 'HP' on one line and '4' on the next, tho a
possible bug was that the two lines were not centered vertically as one
would expect given -gravity center in the command. I had to add
-extent +0-10 to push the two lines down to be centered vertically.
However that is not my real concern.
I "upgraded" to imagemagick-6.8.5 and suddenly the image created
by the command above used such a huge point size that the top of the
"HP" and the bottom of the "4" were cut off. Curiously as I tried other
label verbiage the scaling worked when the lines got wide horizontally.
Therefore I suspect that the newer ImageMagick is failing to consider
the text's vertical size when scaling the text to fit the image size.
I uninstalled the newer version and reinstalled the old version and
all was well again.
convert not using vertical text size for scaling in 6.8.5
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert not using vertical text size for scaling in 6.8.
-extent is an operator that should be performs afetr you have created an image using label:Code: Select all
convert -background lightblue -fill black -size 210x210 \ -gravity center -interline-spacing 0 -extent +0-10 \ -quality 60 label:"HP\n4" x.jpg
Also -quality is a setting for the output image file format and probably should be set just before that point.
Setting options appropriately, I get....
Code: Select all
convert -background lightblue -fill black -size 210x210 \
-gravity center -interline-spacing 0 label:"HP\n4" \
-extent +0-10 \
-quality 60 x.jpg
As for 'fully centering'.. try this..
Code: Select all
convert -background lightblue -fill black -size 210x210 \
-gravity center -interline-spacing 0 label:"HP\n4" \
-trim +repage -extent 210x210 \
-quality 60 x.jpg
Note the -size in this example could be replaced with -pointsize. that way you can control the font size as a separate setting to the final -extent size.
Looking at the the extra information set by label: the above generated a pointsize of 95.2. so making a little smaller say 80, adds a little more border space around the text...
Code: Select all
convert -background lightblue -fill black -pointsize 80 \
-gravity center -interline-spacing 0 label:"HP\n4" \
-trim +repage -extent 210x210 \
-quality 60 x.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: convert not using vertical text size for scaling in 6.8.
Thanks for the reply.
>> Note the -size in this example could be replaced with -pointsize.
>> that way you can control the font size as a separate setting to the final -extent size.
While I admit I do not really understand -extent, I *know* I do not want to
have to set -pointsize manually. I have an automated process which was
relying on 'convert' labels to automatically set an appropriate type point
size depending on the amount and location of the text so as to get the whole
message into the image.
imagemagick-6.7.7 did just that. But something changed in (or before)
imagemagick-6.8.5 such that it no longer adjusted the text point size to fit
properly. Examination of some examples made by imagemagick-6.8.5 suggested
that it was no longer taking the vertical component of text size into
account when limiting the text point size; it appeared to be sizing the text
point size only off of the horizontal text width. If all the lines were narrow
then the image would be too tall and overflow the image vertically.
Personally I think a bug was introduced between the two versions. In any
case I am not going to "upgrade" beyond imagemagick-6.7.7 for a while.
Thanks.
>> Note the -size in this example could be replaced with -pointsize.
>> that way you can control the font size as a separate setting to the final -extent size.
While I admit I do not really understand -extent, I *know* I do not want to
have to set -pointsize manually. I have an automated process which was
relying on 'convert' labels to automatically set an appropriate type point
size depending on the amount and location of the text so as to get the whole
message into the image.
imagemagick-6.7.7 did just that. But something changed in (or before)
imagemagick-6.8.5 such that it no longer adjusted the text point size to fit
properly. Examination of some examples made by imagemagick-6.8.5 suggested
that it was no longer taking the vertical component of text size into
account when limiting the text point size; it appeared to be sizing the text
point size only off of the horizontal text width. If all the lines were narrow
then the image would be too tall and overflow the image vertically.
Personally I think a bug was introduced between the two versions. In any
case I am not going to "upgrade" beyond imagemagick-6.7.7 for a while.
Thanks.
Re: convert not using vertical text size for scaling in 6.8.
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.5-6 Beta available by sometime tomorrow. Thanks.