当前位置: 网学 > 编程文档 > PHP > 正文

php 缩略图实现函数代码

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/22

【编者按】网学网PHP频道为大家收集整理了“php 缩略图实现函数代码“提供大家参考,希望对大家有所帮助!

array getimagesize ( string $filename [, array &$imageinfo ] ) 取得图像大小
resource imagecreatetruecolor ( int $x_size , int $y_size ) 新建一个真彩色图像
resource imagecreatefromjpeg ( string $filename ) 从 JPEG 文件或 URL 新建一图像
bool imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 拷贝部分图像并调整大小
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) 以 JPEG 格式将图像输出到浏览器或文件
复制代码 代码如下:
<?php
/*
Created by <A href="http://www.cnphp.info">http://www.cnphp.info</A>
*/
// 文件及缩放尺寸
//$imgfile = ''smp.jpg'';
//$percent = 0.2;
header(''Content-type: image/jpeg'');
list($width, $height) = getimagesize($imgfile);
$newwidth = $width * $percent;
$newheight = $height * $percent;
$thumb = ImageCreateTrueColor($newwidth,$newheight);
$source = imagecreatefromjpeg($imgfile);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb);
?>

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号