php - imagecopymerge get white background instead of black -


i need merge 2 images , add text it. when code outputs black background. when remove "imagecopymerge" function see white background.

$firsturl = '1.jpg';    $secondurl = "2.jpg"; $a  = getimagesize ($firsturl);      $x = 320; $y = $a[1]+88;  $image = imagecreatetruecolor($x, $y); $white = imagecolorallocate($image, 255, 255, 255);  imagefilledrectangle($image, 0, 0, $x, $y, $white);       $first = imagecreatefromjpeg($firsturl); $second = imagecreatefromjpeg($secondurl);  imagecopymerge($image,$first,0,0,0,0, $x, $y,100); imagecopymerge($image,$second,$a[0]-70,$a[1]+10,0,0, 60, 60,100);      $text_color = imagecolorallocate($image, 51, 51, 51); $font = 'a.ttf'; imagettftext($image, 12, 0, 10, $a[1]+30, $text_color, $font, "text");  header("content-type: image/png"); imagepng($image);  

use width , height of image want insert:

imagecopymerge($image,$first,0,0,0,0,imagesx($first),imagesy($first),100); 

$x , $y dimensions of final image. if $first smaller that, imagecopymerge() fills missing area black.

by using imagesx() , imagesy(), copy exact area of image.


Comments