2010-04-16 4 views
1

이 문제를 해결하는 방법을 찾는 데 실제로 문제가 있습니다. 나는 배경을 검은 색으로 바꿀 수 없다. 그게 어떻게 가능해?이미지의 문자열은 검정색 배경으로 만 생성됩니다.

$string = "foo"; 
$font = 4; 
$width = ImageFontWidth($font) * strlen($string); 
$height = ImageFontHeight($font); 
$im = @imagecreatetruecolor ($width,$height); 
$bg = imagecolorallocate($im, 255, 255, 255); 
$textcolor = imagecolorallocate($im, 0, 0, 0); 
imagestring($im, 5, 0, 0, $string, $textcolor); 
imagegif($im, 'somefile.gif', 8); 
imagedestroy($im); 
+0

imagegif ($ 메신저, 'somefile.gif'를, 8); 5 월 B 두 번째 매개 변수는 전체 경로가 필요하며 여기에는 경로가없고 파일 이름 만 ... 그냥 첵크하십시오. –

답변

0

이 user279470의 대답 통합 :

$string = "foo"; 
$font = 4; 
$width = ImageFontWidth($font) * strlen($string); 
$height = ImageFontHeight($font); 
$im = @imagecreatetruecolor ($width,$height); 
$bg = imagecolorallocate($im, 255, 255, 255); 
imagefill($im, 0, 0, $bg); 
$textcolor = imagecolorallocate($im, 0, 0, 0); 
imagestring($im, 5, 0, 0, $string, $textcolor); 
imagepng($im, 'somefile.png', 8); 
imagedestroy($im); 
관련 문제