如何利用PHP拼接多张图片为一张长图?
黄舟
黄舟 2017-04-10 17:25:58

现有多张短图,拼接成一张长图,如何简单实现?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(2)
伊谢尔伦
 $v) {
    $source[$k]['source'] = Imagecreatefromjpeg($v);
     
    $source[$k]['size'] = getimagesize($v);
     
}
 
//imagecopy ($target_img,$source[0]['source'],2,2,0,0,$source[0]['size'][0],$source[0]['size'][1]);
//imagecopy ($target_img,$source[1]['source'],250,2,0,0,$source[1]['size'][0],$source[1]['size'][1]);
$num1 = 0;
$num  = 1;
$tmp  = 2;
$tmpy = 2; //图片之间的间距
for ($i = 0; $i < 4; $i++) {
    imagecopy($target_img, $source[$i]['source'], $tmp, $tmpy, 0, 0, $source[$i]['size'][0], $source[$i]['size'][1]);
     
    $tmp = $tmp + $source[$i]['size'][0];
    $tmp = $tmp + 5;
    if ($i == $num) {
        $tmpy = $tmpy + $source[$i]['size'][1];
        $tmpy = $tmpy + 5;
        $tmp  = 2;
        $num  = $num + 3;
    }
}
Imagejpeg($target_img, 'pin.jpg');
 
?>
Popular topics
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!