Issues with 'imagefill'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
RitchieTheBrit
Forum Newbie
Posts: 5
Joined: Mon Oct 12, 2009 9:19 am

Issues with 'imagefill'

Post by RitchieTheBrit »

Hi there guys! Quasi-noob here! I normally plod my way through PHP by looking at examples, and logical thinking, but this has me stumped! 8O

I have used a simple verification image for an equally simple contact form for quite a while now, and as basic as it is, I have never seen any spam from it yet. Recently, though, it has broke.

I have two sites hosted with Supanames, and both sites have this problem, though a site hosted elsewhere is fine, so I am guessing it is something the host has changed on the server (they WERE working fine). GD is installed and working, and both the broken sites and the working site are running on the same version of PHP.

THIS is one of the broken examples.
THIS is the working example.

Code: Select all

<?php
header('Content-type: image/jpeg');
$width = 50;
$height = 24;
$my_image = imagecreatetruecolor($width, $height);
imagefill($my_image, 0, 0, 0xFFFFFF);
for ($c = 0; $c < 40; $c++){
    $x = rand(0,$width-1);
    $y = rand(0,$height-1);
    imagesetpixel($my_image, $x, $y, 0x000000);
    }
$x = rand(1,10);
$y = rand(1,10);
$rand_string = rand(1000,9999);
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);
setcookie('tntcon',(md5($rand_string).'a4xn'));
imagejpeg($my_image);
imagedestroy($my_image);
?>
I have tried it using the more common method of imagecolorallocate() as well, but it is exactly the same. It is ignoring the colour used in imagefill(). Has there maybe been a change to the GD library on the faulty server? The white on black works for one site, but the other one could really do with being black on white again.

Cheers guys!
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Issues with 'imagefill'

Post by markusn00b »

Are they (the servers) running the same version of GD. See gd_info()
RitchieTheBrit
Forum Newbie
Posts: 5
Joined: Mon Oct 12, 2009 9:19 am

Re: Issues with 'imagefill'

Post by RitchieTheBrit »

It seems that are both the same....

GD Version: bundled (2.0.28 compatible)
FreeType Support: Enabled
FreeType Linkage: with freetype
T1Lib Support: Disabled
GIF Read Support: Enabled
GIF Create Support: Enabled
JPG Support: Enabled
PNG Support: Enabled
WBMP Support: Enabled
XBM Support: Enabled
JIS-mapped Japanese Font Support: Disabled

:?
RitchieTheBrit
Forum Newbie
Posts: 5
Joined: Mon Oct 12, 2009 9:19 am

Re: Issues with 'imagefill'

Post by RitchieTheBrit »

No ideas anyone?
Post Reply