使用PHP将2-3个透明的PNG图像相互叠加 [英] Combine 2-3 transparent PNG images on top of each other with PHP

查看:148
本文介绍了使用PHP将2-3个透明的PNG图像相互叠加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个项目开发一个自定义的头像系统,但我从来没有真正做过PHP的图像方面。我假设我需要以某种方式使用GD,但我不知道从哪里开始。

I am working on a custom avatar system for a project, but I have never really done much with the image side of PHP. I assume I need to use GD in some way, but I have no idea where to even start.

基本上,有一堆预先制作的透明PNG图像。用户可以选择其中的2-3个来自定义他们的头像,我希望能够拍摄这些图像并将其中的单个图像存储在一个文件夹中。

Basically, there are a bunch of pre-made transparent PNG images. Users can select 2-3 of them to customize their avatar, and I want to be able to take these images and make a single image out of them to be stored in a folder.

推荐答案

$image_1 = imagecreatefrompng('image_1.png');
$image_2 = imagecreatefrompng('image_2.png');
imagealphablending($image_1, true);
imagesavealpha($image_1, true);
imagecopy($image_1, $image_2, 0, 0, 0, 0, 100, 100);
imagepng($image_1, 'image_3.png');

这篇关于使用PHP将2-3个透明的PNG图像相互叠加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆