我想要个网站缩略图PHP源码,就是输入一个网址,点java生成缩略图即可获得网站的缩略图PHP程序,不能用其他API接口

网站标题:
phpjm|php加密|php在线加密|php源码加密|php保护|永久免费
网站简介:
phpjm(www.phpjm.org)是国内最好的php源码免费在线加密保护网站,服务器无需扩展,独有的混淆加密技术使您的php代码坚不可摧,加密后安全无法还原,推荐使用
网站关键字:
phpjm,phpjiami,php加密,php免费加密,php在线加密,php源码加密,最好的php加密
更多查询:
备案情况:
phpjm.org网站综合价值评估简报
Alexa排名:
日IP估值:
日PV估值:
百度权重:
搜狗评级:
百度当日收录
百度本周收录
百度本月收录
phpjm.org网站历史收录
百度索引量
托管地址:
持有人/机构名称:
持有人/邮箱:
注册时间:
到期时间:
域名服务器:
DNS服务器:
域名状态:
------------- 域名详细信息 -------------
&&网站缩略图
&&网站估值
RMB(不含域名价值,品牌价值及其附加值)
&&HTTP状态查询工具
&&最近查询
&&www.yule456.net
&&www.hxxb.net
&&wmcgg.pjkj.pw
&&whjh.whedu.net
&&qingkong.net
&&www.91touch.net
&&www.suhuishou.cc
&&toushijing.org
&&tcb2.cengwu.cc
&&www.kuaida.net
&&zhuangxiuw.
(C) IT号外
版权所有 All Rights Reserved.你的位置: -
共有文章数量: 677 篇
今日更新文章: 0 篇
精品源码数量: 1162 个
今日更新源码: 1 个
源码总的容量: 15.950 G
共有会员数量: 16462 位
今日注册会员: 0 位
源码下载总数: 463839 次
按字母检索
按声母检索php生成缩略图示例代码分享(使用gd库实现)
字体:[ ] 类型:转载 时间:
分享一个利用php的GD库生成缩略图的例子,大家参考使用吧
代码如下:&form method="post" action="suo_do.php" enctype="multipart/form-data"&&& &input type="file" name="pic" /&&& &input type="submit" value="上传1" /&&& &/form&&& &?php&& header("content-type:text/charset=gbk");&& ini_set("date.timezone","Asia/chong");&& //判断文件是否为空&& if(empty($_FILES)){&& echo"上传文件过大";&& && }&& //判断文件上传是否有错误&& if($_FILES['pic']['error']){&& echo "上传文件";&& && }&& //判断文件类型是否非法获取文件后缀&& $allowtype=array("jpg","png","jpeg","gif");&& $a=explode('.',$_FILES['pic']['name']);&& $index=count($a)-1;&& $ex=strtolower($a[$index]);&& if(!in_array($ex,$allowtype)){&& echo "上传文件非法";&& && }&& $file=date('YmdHis').rand().".".$&& $src=$_FILES['pic']['tmp_name'];&& $des="upload/".$&& $rs=move_uploaded_file($src,$des);&& //缩略图&& //读取已经上传图片&& $image=imagecreatefromjpeg($des);&& $a=getimagesize($des);&& $w=$a[0];&& $h=$a[1];&& if($w&$h){&& $width=300;&& $height=$width/$w*$h;&& }else if($w&$h){&& $height=300;&& $width=$height/$h*$w;&& }else{&& $width=300;&& $height=300;&& } www.jb51.net& //创建空白新图片&& $newimage=imagecreatetruecolor($width, $height);&& //copy源图片内容 copy新图片&& imagecopyresized($newimage, $image, 0,0, 0,0, $width, $height, $w, $h);&& $filename="upload/s_".$&& imagejpeg($newimage,$filename);&&
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具PHP生成图片缩略图 - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 20时,
要使用PHP生成图片缩略图,要保证你的PHP服务器安装了GD2图形库 使用一个类生成图片的缩略图
代码片段(2)
1.&[代码]使用方法&&&&
$resizeimage = new resizeimage("图片源文件地址", "200", "100", "0","缩略图地址");
//就只用上面的一句话,就能生成缩略图,其中,源文件和缩略图地址可以相同,200,100分别代表宽和高
2.&[代码][PHP]代码&&&&
//使用如下类就可以生成图片缩略图,
class resizeimage
//图片类型
//实际宽度
//实际高度
//改变后的宽度
var $resize_
//改变后的高度
var $resize_
//是否裁图
//目标图象地址
//临时创建的图象
function resizeimage($img, $wid, $hei,$c,$dstpath)
$this-&srcimg = $
$this-&resize_width = $
$this-&resize_height = $
$this-&cut = $c;
//图片的类型
$this-&type = strtolower(substr(strrchr($this-&srcimg,"."),1));
//初始化图象
$this-&initi_img();
//目标图象地址
$this -& dst_img($dstpath);
$this-&width = imagesx($this-&im);
$this-&height = imagesy($this-&im);
//生成图象
$this-&newimg();
ImageDestroy ($this-&im);
function newimg()
//改变后的图象的比例
$resize_ratio = ($this-&resize_width)/($this-&resize_height);
//实际图象的比例
$ratio = ($this-&width)/($this-&height);
if(($this-&cut)=="1")
if($ratio&=$resize_ratio)
//高度优先
$newimg = imagecreatetruecolor($this-&resize_width,$this-&resize_height);
imagecopyresampled($newimg, $this-&im, 0, 0, 0, 0, $this-&resize_width,$this-&resize_height, (($this-&height)*$resize_ratio), $this-&height);
ImageJpeg ($newimg,$this-&dstimg);
if($ratio&$resize_ratio)
//宽度优先
$newimg = imagecreatetruecolor($this-&resize_width,$this-&resize_height);
imagecopyresampled($newimg, $this-&im, 0, 0, 0, 0, $this-&resize_width, $this-&resize_height, $this-&width, (($this-&width)/$resize_ratio));
ImageJpeg ($newimg,$this-&dstimg);
if($ratio&=$resize_ratio)
$newimg = imagecreatetruecolor($this-&resize_width,($this-&resize_width)/$ratio);
imagecopyresampled($newimg, $this-&im, 0, 0, 0, 0, $this-&resize_width, ($this-&resize_width)/$ratio, $this-&width, $this-&height);
ImageJpeg ($newimg,$this-&dstimg);
if($ratio&$resize_ratio)
$newimg = imagecreatetruecolor(($this-&resize_height)*$ratio,$this-&resize_height);
imagecopyresampled($newimg, $this-&im, 0, 0, 0, 0, ($this-&resize_height)*$ratio, $this-&resize_height, $this-&width, $this-&height);
ImageJpeg ($newimg,$this-&dstimg);
//初始化图象
function initi_img()
if($this-&type=="jpg")
$this-&im = imagecreatefromjpeg($this-&srcimg);
if($this-&type=="gif")
$this-&im = imagecreatefromgif($this-&srcimg);
if($this-&type=="png")
$this-&im = imagecreatefrompng($this-&srcimg);
//图象目标地址
function dst_img($dstpath)
$full_length
= strlen($this-&srcimg);
$type_length
= strlen($this-&type);
$name_length
= $full_length-$type_
= substr($this-&srcimg,0,$name_length-1);
$this-&dstimg = $
//echo $this-&
开源中国-程序员在线工具:
相关的代码(17)
49回/18432阅
4回/5364阅
1回/4348阅
2回/3515阅
4回/3423阅
3回/2530阅
1回/2477阅
0回/2387阅
[JavaScript]
1回/1885阅
3回/1681阅
楼主一定是很老的程序员了,声明变量用var啊,我在类里面声明变量都是用public等,非类里面声明变量就直接写,基本没用var这个东东,呵呵,小鸟见识,还请高手指点,
2楼:Jewel_M 发表于
不管怎么样& 这个得收藏!
3楼:雾渺 发表于
代码阅读起来比较优美,看来确实是老牛啊。哈哈。
4楼:彭哥 发表于
为什么生成的略缩图的像素不高,很模糊
5楼:daoser 发表于
newimg方法中的 ImageJpeg ($newimg,$this-&dstimg);
这句代码,如果提取出来,放在newimg方法的最后会使代码更简洁些。
6楼:gflhx 发表于
引用来自“daoser”的评论newimg方法中的 ImageJpeg ($newimg,$this-&dstimg);
这句代码,如果提取出来,放在newimg方法的最后会使代码更简洁些。生成png格式的缩略图的图片不行,jpg格式的行?这是怎么回事?
7楼:daoser 发表于
引用来自“gflhx”的评论引用来自“daoser”的评论newimg方法中的 ImageJpeg ($newimg,$this-&dstimg);
这句代码,如果提取出来,放在newimg方法的最后会使代码更简洁些。生成png格式的缩略图的图片不行,jpg格式的行?这是怎么回事?代码应该没有问题,我做了些修改,在实际项目中使用了。你可以看下你的php-gd是否配置了 贴出我的部分代码: function resizeImage($hash,$ext,$width,$height,$cut) { //查询是否已经存在该资源 $criteria = new CDbC $criteria-&addCondition('hash_code = &'.$hash.'&'); $model = Images::model()-&find($criteria); if(empty($model)) { $this-&error = '数据库查询为空'; } //加载源文件,生成新文件 $file = $this-&getImagePath($hash); if(!file_exists($file)) { $this-&error = '源文件不存在'; } if($model-&file_extension==&jpg&||$model-&file_extension==&jpeg&||$model-&file_extension==&jpe&) { $new_image = imagecreatefromjpeg($file); } if($model-&file_extension==&gif&) { $new_image = imagecreatefromgif($file); } if($model-&file_extension==&png&) { $new_image = imagecreatefrompng($file); } $src_width = imagesx($new_image); $src_height = imagesy($new_image); //生成图象 //实际图象的比例 $ratio = ($src_width)/($src_height); if(!empty($width) && !empty($height)) { //新输出的图片尺寸 $resize_ratio = ($width)/($height); //裁图 if($cut) { if($ratio&=$resize_ratio)//高度优先 { $begin_width = ($src_width - ($src_height * $resize_ratio))/2; //居中截取 $thumb = imagecreatetruecolor($width,$height); imagecopyresampled($thumb, $new_image, 0, 0, $begin_width, 0, $width,$height, (($src_height)*$resize_ratio), $src_height); }else{//宽度优先 $begin_height = ($src_height - ($src_width / $resize_ratio))/2; //居中截取 $thumb = imagecreatetruecolor($width,$height); imagecopyresampled($thumb, $new_image, 0, 0, 0, $begin_height, $width, $height, $src_width, (($src_width)/$resize_ratio)); } }else{//填补 $thumb = imagecreatetruecolor($width,$height); if($ratio&=$resize_ratio) { $begin_height = ($height - ($width / $ratio))/2; //新图补高度 imagecopyresampled($thumb, $new_image, 0, $begin_height, 0, 0, $width, ($width)/$ratio, $src_width, $src_height); }else{ $begin_width = ($width - ($height * $ratio))/2; //居中截取 imagecopyresampled($thumb, $new_image, $begin_width, 0, 0, 0, ($height)*$ratio, $height, $src_width, $src_height); } } }else{ //只限定一边尺寸,原比例输出 if(!empty($width)) { $thumb = imagecreatetruecolor($width,($width)/$ratio); imagecopyresampled($thumb, $new_image, 0, 0, 0, 0, $width, ($width)/$ratio, $src_width, $src_height); }else{ $thumb = imagecreatetruecolor(($height)*$ratio,$height); imagecopyresampled($thumb, $new_image, 0, 0, 0, 0, ($height)*$ratio, $height, $src_width, $src_height); } } //return $ //ImageJpeg($thumb,$this-&dstimg); //ImageJpeg($thumb,null,75);//以75%质量输出 // ImageJpeg($thumb); //imagepng() - 以 PNG 格式将图像输出到浏览器或文件 //imagegif() - 输出图象到浏览器或文件 //imagewbmp() //保存新文件 $thumb_dir = $this-&getImageThumbDir($hash); if(!file_exists($thumb_dir)) { mkdir($thumb_dir,0755,true); } //缩略图路径 if($cut) $file_name = 'w-'.$width.'_h-'.$height.'_c'.'.'.$ else $file_name = 'w-'.$width.'_h-'.$height.'.'.$ $thumb_file = $thumb_dir.'/'.$file_ if($ext==&jpg&||$ext==&jpeg&||$ext=&jpe&) ImageJpeg($thumb,$thumb_file); if($ext==&gif&) imagegif($thumb,$thumb_file); if($ext==&png&) imagepng($thumb,$thumb_file); ImageDestroy ($new_image);//释放与 image 关联的内存 }
8楼:五杀联盟 发表于
创建不了缩略图 为什么啊
9楼:五杀联盟 发表于
大神求帮忙啊 你这个文件很好用的
10楼:Wicky 发表于
11楼:自主创新 发表于
为什么创建出来的是黑乎乎一片
开源从代码分享开始
小编辑的其它代码软件介绍:摘要:PHP源码,上传下载,PHP图片上传类,文件上传一个安全高效的PHP图片上传类,支持目录自动分割、等比例缩略图多切,也可作为文件上传使用,不过需要做一些修改。本程序主要是上传图片,然后可以按比例自动生成缩略图,官方网页有更多详细的使用实例,欢迎下载使用。通过表单上传后,可在按日期自动生成的文件夹中找到上传的文件,以及自动按比例生成的缩略图文件。
下载地址:
本类推荐下载
本类最新更新
最新网页特效}

我要回帖

更多关于 android 生成缩略图 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信