您现在的位置是:网站首页> 编程资料编程资料
PHP生成缩略图实例讲解_php实例_
2023-05-25
448人已围观
简介 PHP生成缩略图实例讲解_php实例_
封装的方法函数:
= $scale) { //创建真彩图像资源(imagecreatetruecolor()函数使用GDLibrary创建新的真彩色图像) $newimg = imagecreatetruecolor($thumbWidth, $thumbHeight); //图像处理 imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, (($height) * $scale), $height); //以JPEG格式将图像输出到浏览器或文件 ImageJpeg($newimg, $thumbSrc); } //宽度优先 if ($ratio < $scale) { $newimg = imagecreatetruecolor($thumbWidth, $thumbHeight); imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $width, (($width) / $scale)); ImageJpeg($newimg, $thumbSrc); } } else { if ($ratio >= $scale) { $newimg = imagecreatetruecolor($thumbWidth, ($thumbWidth) / $ratio); imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, $thumbWidth, ($thumbWidth) / $ratio, $width, $height); ImageJpeg($newimg, $thumbSrc); } if ($ratio < $scale) { $newimg = imagecreatetruecolor(($thumbHeight) * $ratio, $thumbHeight); imagecopyresampled($newimg, $sourceImg, 0, 0, 0, 0, ($thumbHeight) * $ratio, $thumbHeight, $width, $height); ImageJpeg($newimg, $thumbSrc); } } //销毁图像 ImageDestroy($sourceImg); } ?>调用示例:
到此这篇关于PHP生成缩略图实例讲解的文章就介绍到这了,更多相关PHP生成缩略图内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
您可能感兴趣的文章:
相关内容
- Discuz论坛标题和底部去掉版权信息实例讲解_php实例_
- Thinkphp自定义美化success和error提示跳转页面代码实例_php实例_
- PHP随机生成18位不重复的订单号代码实例_php实例_
- PHP使用Apache的伪静态功能实现“网页404时跳转指定页面_php实例_
- thinkphp5.1的model模型自动更新update_time字段实例讲解_php实例_
- php使用file_get_contents(‘php://input‘)和$_POST的区别实例对比_php实例_
- Thinkphp5.1获取项目根目录以及子目录路径的方法实例讲解_php实例_
- Thinkphp使用Zxing扩展库解析二维码内容图文讲解_php实例_
- WordPress网站访问慢解决方案细图文教程_php技巧_
- php基于redis的分布式锁实例详解_php实例_
