创建图像PHP

时间:2016-07-08 00:00:51

标签: php php-gd

如何让php创建这样的图像?

enter image description here

(显然,没有文字,边框,线条,箭头。)

1 个答案:

答案 0 :(得分:1)

您可以使用GD库。

// Load the three image files:
$images[1]=imagecreatefromjpeg("file1.jpg");
$images[2]=imagecreatefromjpeg("file2.jpg");
$images[3]=imagecreatefromjpeg("file3.jpg");
// Determine their dimensions.
$totalx=$totaly=0;
for ($ix in $images) {
    $img=$images[$ix];
    $totalx+=imagesx($img); // get total width
    $totaly=max($totaly,imagesy($img)); // get maximum height
}
$xm=20; // side and in-between margin
$ym=20; // top and bottom margin
$totalx+=$xmargin*4; // 2 for the outsides and 2 for the in-betweens
$totaly+=$ymargin*2; // for top and bottom
$i=imagecreatetruecolor($totalx,$totaly);
$xstart=0; // where to place the next image
for ($ix in $images) {
    $img=$images[$ix];
    $xstart+=$imagesx($img)+$xm; // increase by this image's width plus buffer
    imagecopy($i,$img,$xstart,$ym,0,0,imagesx($img),imagesy($img));
}
imagepng($i); // this outputs the image data. if you want to write it to a file you can do that with imagepng($i,$filename).

http://php.net/manual/en/ref.image.php