龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

IT趣事网部分核心代码开放:如何在图片底部追加

时间:2014-07-22 14:49来源: 作者: 点击:
分享到:
IT趣事网上线了 希望能在您压力山大的时候带来小小的乐趣。我们的网址是: http://itqushi.com/我们致力于IT工作者的乐趣。废话不多说.作为图片分享站,很多网站都会在上传图片后在图片下
IT趣事网上线了 希望能在您压力山大的时候带来小小的乐趣。
我们的网址是: http://itqushi.com/
我们致力于IT工作者的乐趣。
废话不多说.
作为图片分享站,很多网站都会在上传图片后在图片下方追加自己的logo,在本人长时间的测试下,终于写出了这些代码。
(ps:很对不起,我是做Java的,所以研究php方面的东西有点费力)
作为我宣传我们网站的广告费,给出这段很多人都想要的代码。(大神勿喷,能给代码优化的更好)

下面只是研究出来的雏形,也就是生成图片的效果的代码,至于怎么用,各大站长可以自己修改。

<?php
	$imgPath = 'http://itqiubai.com/imgs/bottom.jpg';
	$mainPath = 'http://img2.aili.com/201301/29/1359446507_22643900.jpg';
	$im = imagecreatefromjpeg($mainPath);
	list($width, $height, $type, $attr) = getimagesize($mainPath); 
	$bottom = imagecreatefromjpeg($imgPath);
	list($width2, $height2, $type2, $attr2) = getimagesize($imgPath); 
	$dest=imagecreatetruecolor($width,$height+$height2);
	imagecopy($dest,$im,0,0,0,0,$width,$height);
	imagecopy(
	$dest, //dst_im
	$bottom, //src_im
	($width-$width2)/2, //dst_x
	$height, //dst_y
	0, //src_x
	0, //src_y
	$width, //src_w
	$height2 //src_h
	);
	
	header('Content-type: image/jpeg');
	imagejpeg($dest);
	imagedestroy($dest) ;
	

?>
精彩图集

赞助商链接