php 缩略图 php 缩略图实现函数代码

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

php 缩略图 php 缩略图实现函数代码

  2021-03-18 我要评论
想了解php 缩略图实现函数代码的相关内容吗,在本文为您仔细讲解php 缩略图的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:缩略图,下面大家一起来学习吧。
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);
?>

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们