사용자가 그림을 업로드 할 때 프로그램이 새로운 흰색 배경 squre 이미지를 생성하고 사용자의 그림을이 이미지의 중앙에 배치합니다.이미지를 생성하는 PHP를 사용, 배경은 항상 잘못된 색상입니다
하지만 문제는 배경을 흰색으로 설정했는데 항상 검은 색으로 표시됩니다.
코드는
$capture = imagecreatetruecolor($width, $height);
$rgb = explode(",", $this->background);
$white = imagecolorallocate($capture, $rgb[0], $rgb[1], $rgb[2]);
imagefill($capture, 0, 0, $white);
과 색상을 제어하는 코드는 내가 $white = imagecolorallocate($capture, 255, 255, 255);
에 $white = imagecolorallocate($capture, $rgb[0], $rgb[1], $rgb[2]);
을 변경하려고했습니다 protected $background = "255,255,255";
입니다. 그러나 배경은 여전히 검은 색으로 표시됩니다. 수동 imagecreatetruecolor() returns an image identifier representing a black image of the specified size.
imagecolorallocate의 첫 번째 통화에서 어떤 대답
"작동하지 않음"이란 무엇을 의미합니까? 배경색은 무엇입니까? 또한 이미지를 어떻게 렌더링하고 있습니까? –
@Zach Rattner 여전히 흰색 대신 검정색으로 표시됩니다. 나는 imagejpeg을 사용하여 이미지를 렌더링한다. – Juni
'''header ('Content-Type : image/jpeg'); $ im = @imagecreatetruecolor (120, 20) 또는 die ('새 GD 이미지 스트림을 초기화 할 수 없습니다'); $ rgb = 폭발 (",", 255,255,255 "); $ white = imagecolorallocate ($ im, $ rgb [0], $ rgb [1], $ rgb [2]); imagefill ($ im, 0, 0, $ white); imagejpeg ($ im);'''나를 위해 작동합니다. 나중에 덮어 쓰지 않으시겠습니까? – Deebster