// Create a blank image with specified dimensions $image = imagecreatetruecolor(200, 50); // Define a color for the background $bg_color = imagecolorallocate($image, 255, 255, 255); // Fill the image with the background color imagefill($image, 0, 0, $bg_color); // Generate a random sequence of characters for captcha verification $text = substr(md5(time()),0,6); // Define a color for the text $text_color = imagecolorallocate($image, 0, 0, 0); // Place the text on the image imagettftext($image, 20, 0, 30, 30, $text_color, 'arial.ttf', $text); // Display the image header('Content-Type: image/png'); imagepng($image); imagedestroy($image);
// Generate a captcha image with specified dimensions $verify = buildImageVerify(200, 50, 6, 'png', 'arial.ttf'); // Display the image header('Content-Type: image/png'); imagepng($verify['image']); imagedestroy($verify['image']);This example uses the buildImageVerify function to generate a PNG image with a random sequence of 6 characters for captcha verification. The function takes parameters for the image dimensions, number of characters, image format, and font.