简体   繁体   中英

Create image in gd library

I am copying image over an image using GD library But it is not showing properly. This is my code:

<?php
$im = imagecreate(288,288);
$background_color = imagecolorallocate($im, 230, 248, 248);
$file = 'images/smiley/smile'.$_POST['smiley'].'.png'; 
$bg = imagecreatefrompng($file);
imagealphablending($bg, true); 
imagesavealpha($bg, true);
imagecopymerge($im, $bg, 10, 10, 0, 0, 100, 47, 25);
?>

i cannot upload image due to not enough reputation but i can explain that when i have a smiley where i have to overlap over an other image but when i run this function a grey color box overlap on the image instead of smiley. Smiley is also in grey color.

Please help...

This is the link for the image create after function runs

http://classicsouls.com/main/9695.png

I want to overlap this image

http://classicsouls.com/main/smile7.png

Try to set imagealphablending also for $im :

$im = imagecreate(288,288);
imagealphablending($im, true); 
$background_color = imagecolorallocate($im, 230, 248, 248);
$file = 'images/smiley/smile'.$_POST['smiley'].'.png'; 
$bg = imagecreatefrompng($file);
imagealphablending($bg, true); 
imagesavealpha($bg, true);
imagecopymerge($im, $bg, 10, 10, 0, 0, 100, 47, 25);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM