You are here: imagecolorallocate - No Effect « PHP Programming Language « IT news, forums, messages
imagecolorallocate - No Effect

Posted by afrinspray on 04/06/06 20:53

I'm having trouble with the imagecolorallocate function. I'm creating
a security image, and the color of the text changes depending on the
background for some reason (ie, for one background the text is always
black, one is always pink, and the other is always yellow).

Any ideas? I'm running Freebsd.

Here's my code:

<?php

include_once('session.php');
include_once('functions.php');

$strCode = randomcode(6);
$_SESSION['strCode'] = $strCode;

$bgdir = 'images/verification/';
$bgs = array('bg1.png', 'bg2.png', 'bg3.png');
$im = ImageCreateFromPNG($bgdir.$bgs[rand(0, count($bgs)-1)]);

$font = '/usr/X11R6/lib/X11/fonts/urwfonts-ttf/n021003l.ttf';

$size = rand(12, 16);
$angle = rand(-5, 5);
//$color = ImageColorAllocate($im, rand(0, 50), rand(0, 50), rand(0,
50));
$color = imagecolorallocate($im, 0, 0, 0);

$textsize = imagettfbbox($size, $angle, $font, $strCode);
$twidth = abs($textsize[2]-$textsize[0]);
$theight = abs($textsize[5]-$textsize[3]);
$x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20));
$y = (imagesy($im))-($theight/2);

imagettftext($im, $size, $angle, $x, $y, $color, $font, $strCode);

header("Content-Type: image/png");
imagepng($im);

imagedestroy($im);

exit;

?>

Thanks,
Mike

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация