• 技术文章 >php教程 >php手册

    php生成图片缩略图的方法

    2016-06-06 20:05:17原创979

    这篇文章主要介绍了php生成图片缩略图的方法,涉及php操作图片的技巧,非常具有实用价值,需要的朋友可以参考下

    本文实例讲述了php生成图片缩略图的方法。分享给大家供大家参考。具体如下:

    这里需要用到GD2 library

    function make_thumb($src,$dest,$desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height*($desired_width/$width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width,$desired_height); /* copy source image at a resized size */ imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image,$dest, 83); }

    希望本文所述对大家的php程序设计有所帮助。

    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:php 生成 图片 缩略图
    上一篇:Laravel 5 框架入门(一) 下一篇:Smarty中的注释和截断功能介绍
    千万级数据并发解决方案

    相关文章推荐

    • XMLHTTP刷新远程数据的PHP JS代码演示(支持中文)• PHP+XML 制作简单的留言本 图文教程• PHP常用代码• 第十四节 命名空间 [14]• 初学PHP的18个基础例程
    1/1

    PHP中文网