我想用PHP创建照片拼贴。我创建了一个测试代码在我的本地如下:如何为php文件输出创建图像
<style type="text/css">
body{background:url('images/Winter.jpg'); }
#collage:after{content:"";clear:both;display:block;}
}
</style>
<?php
ob_start();
$dir = "images";
if($fp = opendir($dir))
{
while($file = readdir($fp))
{
if('jpg'==(pathinfo($file, PATHINFO_EXTENSION)))
{
$style = "style='float:left; -webkit-transform:rotate(".mt_rand(2, 30)."deg); border:solid 5px #eee;'";
$ht = "height='".mt_rand(100, 300)."'";
echo "<div class='img_div' $style>";
echo "<img src='$dir/$file' $ht >";
echo "<div style='background:#eee;font-size:20px;'>hi</div>";
echo '</div>';
}
}
}
closedir($fp);
?>
它产生的,我想要的输出,但现在我希望用户可以下载它作为一个图像文件。我该怎么做?
谢谢jeroen我会尝试gd库,但它有点痛苦的使用它。我正在考虑使用imagick,但我不知道如何安装和使用它。 –