2012-12-20 5 views
-2

PHP GD를 사용하여 이미지를 동적으로 생성합니다. 나는 그것이의 image.png를 만들 index.php를 실행하지만, 예를 들어 index.php에있는 이미지를 원하는 경우에 따라서 나는 당신은 내가 한 번씩 비슷한 코드를 구현 한 header('content-type: image/jpeg');
에 헤더 내용 유형을 설정해야 <img src="index.php">이미지를 동적으로 생성 - PHP GD

+0

http://stackoverflow.com/questions/2010742/image-processing-and-output-using-gd-in-php – ke20

답변

4

을 사용할 수 있습니다 보안 문자

header("Content-type: image/png"); 
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past 
$string = "Type Me"; 
$im  = imagecreatefrompng(IMAGEDIR."captcha.png"); 
$orange = imagecolorallocate($im, 0, 0, 0); 
$px  = (imagesx($im) - 7.5 * strlen($string))/2; 
imagestring($im, 5, $px, 9, $string, $orange); 
imagepng($im); 
imagedestroy($im);