Very strange behaviour of imageftbbox()?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

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 it calls this

and subtracts it from the X value of the text center


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


function textoffset($size,$font,$string)
    $tmp=imageftbbox( $size, 0.0,$font,$string);

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?

Re: Very strange behaviour of imageftbbox()?

Quoted text here. Click to load it

What creates these files in the first place?  How are unique names
guaranteed?  What guarantee is there that one of the files won't
be overwritten by one of the other files, *WHILE* your code is

Quoted text here. Click to load it

Site Timeline