## caption is breaking words... ugh

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?".
immortal26

### caption is breaking words... ugh

BUT
with a function as easy as:
convert -size (whatever size) -font myfont.ttf -background black -fill white caption:'jennifer winningham' comp.png

everything is irrelevant really because if I don't specify a pointsize imagemagick is supposed to fit it correctly, so specifeng size.

So if the caption was "Jennifer Winningham".. it's outlaying like this:
Jennifer
Wiinning
ham

ummmm, what's going on? lol
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

### Re: caption is breaking words... ugh

Everything is not irrelavent; if you have a long thin box it will be on one line but if you have a tall narrow box it will break up the text so what did you use for the size?
immortal26

### Re: caption is breaking words... ugh

Well silly me your right... hmmm... I just used a simple size of 100x100.. here is the exact code with simple syntax.

Code: Select all

``````<?php

// Set the path of convert command for imagemagick
\$path = "/opt/local/bin/";

// Set which font we want to use
\$font = "font/trace_edit.ttf";
\$capfont = "font/corbel.ttf";

\$text = "Jennifer\nwinningham";

\$final = \$path."convert -size 100x100 -font ".\$capfont." -background black -fill white caption:\"".\$text."\" final.png";
exec(\$final, \$result);

?>``````
I could have swore caption resizes the pointsize to fill correctly, and not to break the word.
and not:
Jennifer
winning
ham
magick
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

### Re: caption is breaking words... ugh

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.4-6 Beta available by sometime tomorrow. Thanks.
immortal26

### Re: caption is breaking words... ugh

thanks magick ... knew something was amiss here
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

### Re: caption is breaking words... ugh

Well spotted I was not thinking about the word being split and have just tried it and have the same problem on 6.5.9

Out of interest I do not use the ( can not remember the word for it ) ". ." around variables and it still works and so would use;

Code: Select all

``````\$final = "\$path convert -size 100x100 -font \$capfont -background black -fill white caption:\"\$text\" final.png";
``````
Not sure about the \$path at the start as didn't test that. I tend to use convert all the time and so I would add the convert to the \$path variable.
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

### Re: caption is breaking words... ugh

ASIDE:
Bonzo wrote:Out of interest I do not use the ( can not remember the word for it ) ". ." around variables and it still works and so would use;

Code: Select all

``````\$final = "\$path convert -size 100x100 -font \$capfont -background black -fill white caption:\"\$text\" final.png";
``````
Not sure about the \$path at the start as didn't test that. I tend to use convert all the time and so I would add the convert to the \$path variable.
You will need to some how append without spaces \$path and convert EG: \$pathconvert however as that can not posibly work you also need to soemhow delimit the variable name in most languages (shell perl etc., don't know PHP) you use \${..} so that should be... "\${path}convert ...."

however you can also use "\$path/convert ..." as it does not matter if the slash on the end of \$path gets doubled or not.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
immortal26

### Re: caption is breaking words... ugh

Hey Magick,

Anything on a new patch for caption yet?

Immortal
magick
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

### Re: caption is breaking words... ugh

The patch is available now in ImageMagick 6.6.4-6 Beta. 6.6.4-6 will be released within a few days.
immortal26

### Re: caption is breaking words... ugh

Hey Magick,

I appreciate all the help, but it seems I stumbled upon another problem with caption.
When trying to use kerning is seems to still wrap in the middle of a word without reducing the pointsize.
I would hope kerning would work... can you reproduce a kerning problem with latest build you released with caption.

Thanks again for the help.
magick
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

### Re: caption is breaking words... ugh

Post a caption command that fails. We need to reproduce the problem before we can comment.
immortal26

### Re: caption is breaking words... ugh

Code: Select all

``\$final = \$path."convert  -font ".\$capfont." -kerning 40 -background black -gravity center -fill white -size 1000x500 caption:\"".\$text."\" final.png";``
magick
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

### Re: caption is breaking words... ugh

What is an example text? We tried your command with a some text and the caption appeared ok. Are you using Windows or Linux?
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

### Re: caption is breaking words... ugh

Just a thought, but perhaps his very large -kerning 40 is putting so much space between characters that IM is having a hard time distinguishing words.

Does this word breaking happen with a small or no kerning?
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

### Re: caption is breaking words... ugh

fmw42 wrote:Just a thought, but perhaps his very large -kerning 40 is putting so much space between characters that IM is having a hard time distinguishing words.

Does this word breaking happen with a small or no kerning?
word delimiting would not depend on kerning which is simply passed to the font rendering library.
All it does is make the words longer, so Im has trouble fitting the words into the specified width.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/