Issue
I want to make an image "onfly" with some text. Is it possible with php? I am trying with this one but no output is coming can anyone watch my code please?
function createCaptcha($string){
$image = PATH_DIR . "blueprint/images/bg6.png";
$text_vertical_position = 97;
$font_size = 15;
$color = '32a53d';
Header ("Content-type: image/png");
$color = convert_to_rgb($color);
$info = GetImageSize($image);
$width = $info[0];
$height = $info[1];
if (preg_match("/.gif/", $image)) {
$image = imageCreateFromGif($image);
} elseif (preg_match("/.png/", $image)) {
$image = imageCreateFromPng($image);
} elseif (preg_match("/.jpg/", $image)) {
$image = imageCreateFromJpeg($image);
} elseif (preg_match("/.jpeg/", $image)) {
$image = imageCreateFromJpeg($image);
}
$imgcolor = ImageColorAllocate ($image, $color[0], $color[1], $color[2] );
imagettftext($image, $font_size, 0, $start_length, $text_vertical_position,
$imgcolor, $font , $text);
ImagePNG ($image);
ImageDestroy ($image);
}
I am using codeigniter to make it.
Thank You
Solution
It seems you made a mistake in parameter of the function: $string
not $text
imagettftext($image, $font_size, 0, $start_length, $text_vertical_position,
$imgcolor, $font, $string);
PS. If you make captcha - it would not reliable without any additional distortion of the image.
Why not to use ready-made solutions?
http://www.captcha.ru/kcaptcha/
Answered By - mantigatos Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.