使用修复了这个问题图像复制合并() http://php.net/manual/en/function.imagecopymerge.php :
<?php
CreateMyCoolOutfitBaby ();
function CreateMyCoolOutfitBaby () {
$Outfitwidth = 250;
$Outfitheight = 350;
$newoutfit = imagecreatetruecolor($Outfitwidth, $Outfitheight); // create empty new image
imagealphablending($newoutfit, true);
$black = imagecolorallocate($newoutfit, 0, 0, 0);imagecolortransparent($newoutfit, $black); // Making it transparent
$dress = imagecreatefromstring(file_get_contents('http://example.com/dress.jpg'));
imagealphablending($dress, true);
$white = imagecolorallocate($dress, 255, 255, 255);
imagecolortransparent($dress, $white);
$bag = imagecreatefromstring(file_get_contents('http://example.com/bag.jpg'));
imagealphablending($bag, true);
$white = imagecolorallocate($bag, 255, 255, 255);
imagecolortransparent($bag, $white);
$shoe = imagecreatefromstring(file_get_contents('http://example.com/shoe.jpg'));
imagealphablending($shoe, true);
$white = imagecolorallocate($shoe, 255, 255, 255);
imagecolortransparent($shoe, $white);
// get with and height from images
$Dresswidth = imagesx($dress); $Bagwidth = imagesx($bag); $Shoewidth = imagesx($shoe);
$Dressheight = imagesy($dress); $Bagheight = imagesy($bag); $Shoeheight = imagesy($shoe);
// Calc Dress Position (middle)
$DressPosWidth = ( ( $Outfitwidth / 2 ) - ( $Dresswidth / 2 ) );
$DressPosHeight = ( ( $Outfitheight / 2 ) - ( $Dressheight / 2 ) );
// Calc Bag Position (right beside dress)
$BagPosWidth = ( ( $Outfitwidth / 2 ) - ( $Bagwidth / 2 ) + 60 ); // place bag in middle but more to the right
$BagPosHeight = ( ( $Outfitheight / 2 ) - ( $Bagheight / 2 ) );
// Calc Shoe Position (middle under dress)
$ShoePosWidth = ( ( $Outfitwidth / 2 ) - ( $Shoewidth / 2 ) );
$ShoePosHeight = ( ( $Outfitheight / 2 ) - ( $Shoeheight / 2 ) + 100); // place further down
// merge images together
imagecopymerge($newoutfit,$dress,$DressPosWidth,$DressPosHeight,0,0,$Dresswidth,$Dressheight,100);
imagealphablending($newoutfit,true);
imagecopymerge($newoutfit,$bag,$BagPosWidth,$BagPosHeight,0,0,$Bagwidth,$Bagheight,100);
imagealphablending($newoutfit,true);
imagecopymerge($newoutfit,$shoe,$ShoePosWidth,$ShoePosHeight,0,0,$Shoewidth,$Shoeheight,100);
imagealphablending($newoutfit,true);
header('Content-Type: image/png');
imagepng($newoutfit); // output to the browser
imagedestroy($newoutfit);
}