PHP - 从图像创建一个图像 [英] PHP - Create one image from images

查看:112
本文介绍了PHP - 从图像创建一个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有n个图像,想要用PHP代码创建一个。我使用imagecopymerge(),但无法实现。请问一些例子吗?

i have n-images and want to create one with php code. I use imagecopymerge(), but can't make it. Some example please?

推荐答案

代码:

$numberOfImages = 3;
$x = 940;
$y = 420;
$background = imagecreatetruecolor($x, $y*3);


$firstUrl = '/images/upload/photoalbum/photo/1.jpg';

$secondUrl = '/images/upload/photoalbum/photo/2.jpg';

$thirdUrl = '/images/upload/photoalbum/photo/3.jpg';

$outputImage = $background;

$first = imagecreatefromjpeg($firstUrl);
$second = imagecreatefromjpeg($secondUrl);
$third = imagecreatefromjpeg($thirdUrl);



imagecopymerge($outputImage,$first,0,0,0,0, $x, $y,100);
imagecopymerge($outputImage,$second,0,$y,0,0, $x, $y,100);
imagecopymerge($outputImage,$third,0,$y*2,0,0, $x, $y,100);

imagejpeg($outputImage, APPLICATION_PATH .'/images/upload/photoalbum/photo/test.jpg');

imagedestroy($outputImage);

这篇关于PHP - 从图像创建一个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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