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

Post by immortal26 »

Firstly running latest version... have all depend.. etc...

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

Post by Bonzo »

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

Post by immortal26 »

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);

header("Location: final.png");

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

Re: caption is breaking words... ugh

Post by magick »

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

Post by immortal26 »

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

Re: caption is breaking words... ugh

Post by Bonzo »

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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: caption is breaking words... ugh

Post by anthony »

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

Post by immortal26 »

Hey Magick,

Anything on a new patch for caption yet?
Thanks in advance!

Immortal
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: caption is breaking words... ugh

Post by magick »

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

Post by immortal26 »

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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: caption is breaking words... ugh

Post by magick »

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

Re: caption is breaking words... ugh

Post by immortal26 »

Code: Select all

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

Re: caption is breaking words... ugh

Post by magick »

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

Re: caption is breaking words... ugh

Post by fmw42 »

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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: caption is breaking words... ugh

Post by anthony »

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/
Post Reply