2009-10-16 6 views

답변

7

Create a new truecolor image resource (t) same dimensions을 소스 이미지로 사용하고, copy (s)부터 (t)까지.

(오류 처리없이) :

$imgSource = imagecreatefromgif('xyz.gif'); 
$width = imagesx($imgSource); 
$height = imagesy($imgSource); 
$imgTC = imagecreatetruecolor($width, $height); 
imagecopy($imgTC, $imgSource, 0, 0, 0, 0, $width, $height); 
// save or send $imgTC 

당신은 GD2 형식의 메모리에 두 이미지해야합니다, 당신이 더 큰 이미지로 이것을 시도하기 전에 당신의 memory_limit 설정을 확인 있도록 (픽셀 당 4 바이트를 5?).

0

빠르고 쉽고 적은 메모리 사용량이 해결 방법이 있습니다 PHP 5.5 이후 : 그냥 사용하는 imagepalettetotruecolor PHP 함수 :

$imgSource = imagecreatefromgif('xyz.gif'); 
if (!imageistruecolor($imgSource)) { 
    imagepalettetotruecolor($imgSource); 
} 
관련 문제