FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Very strange behaviour of imageftbbox()?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Very strange behaviour of imageftbbox()? [message #173006] Wed, 16 March 2011 18:04 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
I am chasing a very very weird bug..

I have some code, which works 100% solidly on one machine, but
*randomly* fails WITH EXACTLY THE SAME INPUT DATA on another.

That is, when involved with the same data, it works, or sometimes it
doesn't.

What the bit of code does, is center a bit of text in an image. To do
this, it needs to know how wide the text is..so it calls this

and subtracts it from the X value of the text center

e.g.

imagettftext ( $image ,$fontsize,0,
$dest_x+$cx - textoffset($fontsize,$font,$label),
$dest_y+$cy-80,$ivory ,$font,$label);

and..

function textoffset($size,$font,$string)
{
$tmp=imageftbbox( $size, 0.0,$font,$string);
return(($tmp[2]-$tmp[0])/2);
}

On one machine with as near as I can judge identical software, albeit on
a 32 bit rather than 64 bit platform, sometimes the text is in the right
place, but sometimes it's displaced well to the right, and sometimes
it's simply not there at all - presumably right off the edge of the
image altogether.

Now I stress that this does not change with the parameters supplied to
the program. The same parameters to the same program will produce
different results depending on some condition I have not established.

Now for a bit more information. The actual php code is used to generate
these images is called by <img> statements in another php program's output.

If a single instance of this code is running, I have not yet made it break.

BUT if I call up several instances - i.e. the web browser calls for
half a dozen instances of the program simultaneously via several
slightly different <img> statements in the same page, that seems to be
when the problem happens.


Is it possible that some part of the GD library is not re-entrant?

That's the only thing I can think of..or do you know better?
[Message index]
 
Read Message
Read Message
Previous Topic: Failed @getimagesize() print to error_log?
Next Topic: ip address of client
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 12 19:36:09 GMT 2024

Total time taken to generate the page: 0.07214 seconds