我需要将ImageCreateTrueColor
的背景颜色更改为白色,然后在其上放置图像
elseif(($height>50)&&($width<50))
{
$img_r = imagecreatefromjpeg($new_img_path);
$source = ImageCreateTrueColor(50, 50);
imagetruecolortopalette($source, FALSE, 2);
$bg = imagecolorat($source, 0, 0);
imagecolorset($source, $bg, 0, 0, 255);
// $white = imagecolorallocate($source,255,255,255);
// imagefilledrectangle($source, 0, 0, 50, 50, $white);
imagecopy($source, $img_r,0,0,0,0,$width,50);
header('Content-type: image/jpeg');
imagejpeg($source, $small_new_img_path);
这里是蓝色,但没关系,它不会将图像放在蓝色背景上