-2
問題は、サイズ変更された画像は黒い背景です、私はここにいくつかの問題があることを見たが、私はそれを作ることができない!私はすべてを試みた、あなたは私を助けることができますか?おかげでここに私のコードです:画像のサイズ変更php黒の背景
header ("Content-type: image/png");
// Traitement de l'image source
$source = imagecreatefrompng(_PS_IMG_DIR_.'test/toasty.png');
$largeur_source = imagesx($source);
$hauteur_source = imagesy($source);
imagealphablending($source, true);
imagesavealpha($source, true);
$nWidth = 400;
$nHeight = 400;
$newImg = imagecreatetruecolor($nWidth, $nHeight);
imagealphablending($newImg, true);
imagesavealpha($newImg,true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $nWidth, $nHeight, $transparent);
imagecopyresampled($newImg, $source, 0, 0, 0, 0, $nWidth, $nHeight,
$srcWidth, $srcHeight);
$resize = _PS_IMG_DIR_.'test/resize.png';
imagepng($newImg, $resize);
$source = $newImg;
// Traitement de l'image destination
$destination = imagecreatefrompng(_PS_IMG_DIR_.'test/toaster.png');
$largeur_destination = imagesx($destination);
$hauteur_destination = imagesy($destination);
// Calcul des coordonnées pour placer l'image source dans l'image de destination
$destination_x = ($largeur_destination - $largeur_source)/2;
$destination_y = ($hauteur_destination - $hauteur_source)/2;
// On place l'image source dans l'image de destination
//imagecopymerge($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source, 100);
imagecopy($destination, $source, $destination_x, $destination_y, 0, 0, $largeur_source, $hauteur_source);
$trost = _PS_IMG_DIR_.'test/trost.png';
// On affiche l'image de destination
imagepng($destination ,$trost);
imagedestroy($source);
imagedestroy($destination);
このコードは現在何をしていますか?ログにはどのようなエラーがありますか? – mkaatman