I have an image and an image sprite. I want to merge certain parts of the sprite on top of the image. I have got this working with just one part of the sprite, however when the sprite is merged on top of the image, the sprite loses its transparency.
$image = $homepath.'/images/orig.png';
$sprite = $homepath.'/images/sprite.png';
$image = imagecreatefromstring(file_get_contents($image));
$sprite = imagecreatefromstring(file_get_contents($sprite));
imagecopymerge($image, $sprite, 50, 50, 80, 0, 80, 100, 100);
imagepng($image, $homepath.'/images/output.png');
Example output: http://i.imgur.com/ZyL9D.png Whatever the dimensions are that I set for the sprite is what has a background color. The co开发者_StackOverflow中文版lor is the same color as the sprite. So in the case, the word "text" are part of the sprite, but if this text was green, the rectangle would be green.
///EDIT///
Figured it out: imagecopyresampled
You probably want another gd
function: imagecopyresampled
.
精彩评论