首页 > 代码库 > PHP将多张小图拼接成一张大图
PHP将多张小图拼接成一张大图
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php $imgs = array(); $imgs[0] = ‘imgs/1.jpg‘; $imgs[1] = ‘imgs/2.jpg‘; $imgs[2] = ‘imgs/3.jpg‘; $imgs[3] = ‘imgs/4.jpg‘; $imgs[4] = ‘imgs/5.jpg‘; $imgs[5] = ‘imgs/6.jpg‘; $imgs[6] = ‘imgs/7.jpg‘; $imgs[7] = ‘imgs/8.jpg‘; $imgs[8] = ‘imgs/9.jpg‘; $target = ‘bg.jpg‘; //背景图片 $target_img = Imagecreatefromjpeg($target); $source = array(); foreach ($imgs as $k => $v) { $source[$k][‘source‘] = Imagecreatefromjpeg($v); $source[$k][‘size‘] = getimagesize($v); } /*echo "<pre>"; print_r($source); echo "</pre>";*/ //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 = 2; $tmp = 0; $tmpy = 0; //图片之间的间距 for ($i = 0; $i < 10; $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 + 0; if ($i == $num) { $tmpy = $tmpy + $source[$i][‘size‘][1]; // $tmpy = $tmpy + 0; $tmp = 0; $num = $num + 3; } } Imagejpeg($target_img, ‘pin.jpg‘); ?> <img src="http://www.mamicode.com/pin.jpg">
PHP将多张小图拼接成一张大图
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。