Page 1 of 1

New user and having an issue with Caption

Posted: 2008-06-15T10:51:04-07:00
by RacerX
I will state that I am new to IM but do php programming.

I have IM installed on my Windows machine (as I wait for my host to update my server) and I am attempting to use caption to generate an image of a specified size with the text as large as possible to fill the area. It works unless I try to outline the text, then the text only fills one line and doesn't wrap. I have searched for any fixes but no such luck.

The command I am running that works great (but no outlining) is
convert.exe -background transparent -fill blue -font c:\inetpub\wwwroot\fonts\coopblk.ttf -size 2000x1000 -gravity Center caption:"MAKE TEXT AS LARGE AS POSSIBLE" caption_filled.png

The command I am using for outlining is
convert.exe -background transparent -fill blue -font c:\inetpub\wwwroot\fonts\coopblk.ttf -stroke black -strokewidth 15 -size 2000x1000 -gravity Center caption:"MAKE TEXT AS LARGE AS POSSIBLE" caption_filled.png

If I set the strokewidth to zero, then it sizes to large as possible, so it seems related to that causing an issue. Any ideas would be appreciated :)

TIA

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-15T12:10:45-07:00
by Bonzo
Running XAMPP on my windows XP machine these both work. I would write the code as the second example with the -size first

Code: Select all

<?php

exec("convert -background transparent -fill blue -font ../verdana.ttf -stroke black -strokewidth 15 -size 2000x1000 -gravity Center caption:\"MAKE TEXT AS LARGE AS POSSIBLE\" caption_filled.png");

exec("convert -size 2000x1000 -background transparent -font ../verdana.ttf -fill blue -stroke black -strokewidth 15 -gravity Center caption:\"MAKE TEXT AS LARGE AS POSSIBLE\" caption_filled1.png");
?>
And this works from the Command prompt - I have taken out the -font as I do not know what the path to my fonts are.

Code: Select all

convert -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -gravity Center caption:"MAKE TEXT AS LARGE AS POSSIBLE" caption_filled1.png

Re: New user and having an issue with Caption

Posted: 2008-06-15T12:34:59-07:00
by RacerX
Thanks for the reply... what you posted did work for me... so maybe size in front had an effect. But I am seeing something weird still.

If I use this, it wraps fine...
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"MAKE TEXT AS LARGE AS POSSIBLE" caption_filled1.png

If I change the text to be "Vote for Obama", It does not wrap...
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBAMA" caption_filled1.png

However, if I leave the font out as follows, it does work...
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -gravity Center caption:"VOTE FOR OBAMA" caption_filled1.png

The same text behaves differently depending on the font I choose. I thought it might be the font, but the first command line in this post works just fine with that font. So it is working some of the time, but obviously not all. Maybe the text string length has some effect? I will run a few tests to see.

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-15T12:50:43-07:00
by RacerX
Okay I ran a few tests to see if the length has a issue...

Doesn't Wrap
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTES FOR OBAMA" caption_filled1.png
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBAMAS" caption_filled1.png
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBAM" caption_filled1.png
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR BARACK" caption_filled1.png

Works and does wrap
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBA" caption_filled1.png
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR ME" caption_filled1.png
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR BARACKS" caption_filled1.png

I also thought I would see if rearranging them to see if the spaces had an issue... "OBAMA FOR VOTE" "FOR VOTE OBAMA" "VOTE-FOR OBAMA" don't wrap either.

However, "VOTEFOR OBAMA" does work.

So maybe there is some really odd issue someplace between that font and label in a a few vary specific cases.

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-15T13:04:28-07:00
by RacerX
Well I ran some more testing...

If use a border of 2, it wraps fine
convert.exe -size 2000x1000 -background transparent -fill blue -stroke black -strokewidth 2 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBAMA" caption_filled1.png


if I change the width to 2100, it wraps with a larger stroke of 15 it wraps
convert.exe -size 2100x1000 -background transparent -fill blue -stroke black -strokewidth 15 -font c:\inetpub\wwwroot\fonts\coopblk.ttf -gravity Center caption:"VOTE FOR OBAMA" caption_filled1.png

Since what I need it for, the input can be anything so I guess I will have to live with an occasional issue (since using GD will be alot more coding on my end) and since I started looking at IM, there is alot more felxibility and power for what I want to do. I can increase the width but I am sure this will appear for some other string. I do have to keep a consistent width and height for my project.

I just always seem lucky to find odd glitches :)

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-15T13:28:27-07:00
by Bonzo
They are strange results, it must be the way the wordwrap is calculated ?

If you want some more ideas about IM and php take a look at my site.
I have noticed that it is hard to find what you are looking for on my site and am currently working on a "snippets" section hopefuly with a search function.

Re: New user and having an issue with Caption

Posted: 2008-06-15T14:13:14-07:00
by RacerX
Yeah, an issue with word wrap is my guess as well. Thanks for looking again.

I did check out your site and have a few things I want to look at closer.

I have been using GD alot and there are a few things that IM can do natively, like the arched text, shading, and outlining... of course I have written my own outlining and shading routines for GD and know how to program the arched text, but IM seems alot less processor intensive that GD for large files. I already have 3 sites power by GD to generate 3 to 5 megapixel images and I want to see if I can reduce server load as I move forward. Since it has the ability to size text for an image, that interested me. Since GD doesn't have that functionality, I wrote a routine to use the ttfbox to calculate the largest text possible for a given width so I can maximize image quality and keep the sizes down for memory usage.

Sometimes the problem is getting the software to match what I see in my head...lol Of course I only started looking at IM three days ago in my spare time, so there is alot I don't know. Done alot of reading though.

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-15T17:20:59-07:00
by anthony
Could your problem be related to changing the 'strokewidth'.
This setting does change the size, and spacing of the drawn characters, which could effect caption word wrapping. It is an aspect that may not have been fully tested.

Re: New user and having an issue with Caption

Posted: 2008-06-16T18:38:19-07:00
by RacerX
hi Anthony,
It could very well be related to that. I have changed the stroke thickness and it does wrap in some cases. I assumed I found a very narrow case that causes the problem. I am going to run some image generations and see how often it appears (well after I figure out why something else I am trying to do doesn't work)

Micheal

Re: New user and having an issue with Caption

Posted: 2008-06-16T19:11:03-07:00
by anthony
If you want to combine images with different stroke widths, I suggest you use the same strokewidth for all those images, but set stroke color to 'none' to make the stroke invisible ;)