JAVA、PHP、前端、APP、网站开发 - 开发技术学习

开发技术学习 » 编程开发 » php复制图片并对进行截取

php复制图片并对进行截取

此文被围观2560日期: 2012-11-01 分类 : 编程开发  标签:  ·····
昨天做了一个远程地址的图片,要将远程的图片保存到地本,然后还要生成缩略图, php截取图片,php缩略图,php生成缩略图,php如何生成缩略图 如何下载远程图片,我在前面的一篇文章中有涉及,这里就不多说了; 下面我们主要看一下,如何将图片生成缩略图:  [sourcecode plain="language"][/sourcecode] /** * 复制图片并对其进行截取 * @dir image * @filename * @thumb * @width * @height **/ function DrawImage($dir,$filename,$thumb='',$width='160',$height='120'){ $str_file = $dir.$filename; $out_file = $dir.$thumb.$filename; // Content type header('Content-type: image/jpeg'); $size=getimagesize($str_file); if($size[2]==1) $im_in=imagecreatefromgif($str_file); if($size[2]==2) $im_in=imagecreatefromjpeg($str_file); if($size[2]==3) $im_in=imagecreatefrompng($str_file); $im_out=imagecreatetruecolor($width,$height); imagecopyresampled($im_out,$im_in,0,0,0,0,$width,$height,$size[0],$size[1]); //输出新的图片 imagejpeg($im_out,$out_file); //更改权限 chmod($str_file,0777); imagedestroy($im_in); imagedestroy($im_out); } [sourcecode][/sourcecode]

站点声明:部分内容源自互联网,为传播信息之用,如有侵权,请联系我们删除。

© Copyright 2011-2024 www.kfju.com. All Rights Reserved.
超级字帖 版权所有。蜀ICP备12031064号