0

の背景の色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);

ここに青がありますが、問題ではありません。画像を青の背景に配置することはありません

4

1 に答える 1

1

JPEGではなくpngを作成したい。とを使用imagepngimagesavealphaます。

完全な例を参照してください。

于 2013-07-18T08:16:43.350 に答える