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 » 2010-09-22T11:02:30-07:00

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 » 2010-09-22T11:09:46-07:00

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 » 2010-09-22T11:28:08-07:00

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: 11015
Joined: 2003-05-31T11:32:55-07:00

Re: caption is breaking words... ugh

Post by magick » 2010-09-22T12:17:59-07:00

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 » 2010-09-22T12:21:20-07:00

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 » 2010-09-22T12:35:20-07:00

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 » 2010-09-22T18:31:42-07:00

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 » 2010-09-23T13:02:27-07:00

Hey Magick,

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

Immortal

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

Re: caption is breaking words... ugh

Post by magick » 2010-09-23T16:30:32-07:00

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 » 2010-09-24T09:53:23-07:00

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: 11015
Joined: 2003-05-31T11:32:55-07:00

Re: caption is breaking words... ugh

Post by magick » 2010-09-24T11:15:00-07:00

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 » 2010-09-24T11:50:08-07:00

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: 11015
Joined: 2003-05-31T11:32:55-07:00

Re: caption is breaking words... ugh

Post by magick » 2010-09-24T12:17:36-07:00

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: 25270
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: caption is breaking words... ugh

Post by fmw42 » 2010-09-24T13:41:36-07:00

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 » 2010-09-26T18:34:38-07:00

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