php add a picture onto another

两盒软妹~` 提交于 2019-11-28 11:57:27

问题


I would like to change the color of an image with php. if I wanted to make it appear redder applicherei an image on a higher level across an image with a transparent red and more or less high can indicate how the original photo should be red. I can say gd php functions to create an image of a color (RGBA) and apply it to another image? thanks :)


回答1:


You can try using GD's imagecopymerge function, which copies one image to another and supports alpha transparency. Something like this should work:

<?php
$redimg = imagecreatetruecolor(100, 100);
$image = imagecreatefrompng('image.png');

// sets background to red
$red = imagecolorallocate($redimg, 255, 0, 0);
imagefill($redimg, 0, 0, $red);

// Merge the red image onto the PNG image
imagecopymerge($image, $redimg, 0, 0, 0, 0, 100, 100, 75);

header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
imagedestroy($redimg);
?>

There's more information here.



来源:https://stackoverflow.com/questions/10597227/php-add-a-picture-onto-another

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!