【php实现图片等比例缩放代码,_PHP教程】教程文章相关的互联网学习教程文章

如何实现php图片等比例缩放_php技巧

通过文章给出的源代码可实现针对图片的等比缩放生成缩略图的功能,非常实用的技巧哦。 新建文件index.php,需要在统计目录下有个图片为pic.jpg(可根据源码进行更改图片的名称) 源代码如下: <?php $filename="pic.jpg"; $per=0.3; list($width, $height)=getimagesize($filename); $n_w=$width*$per; $n_h=$height*$per; $new=imagecreatetruecolor($n_w, $n_h); $img=imagecreatefromjpeg($filename); //copy部分图像并调整 imag...

php缩放图片(根据宽高的等比例缩放)实例介绍

推荐一个简单实用的缩放图片工具 SimpleImage,参考http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ 使用方法: 设定宽高,不等比例缩放 代码如下:<?php include(SimpleImage.php); $image = new SimpleImage(); $image->load(picture.jpg); $image->resize(250,400); $image->save(picture2.jpg);?> 设定宽度,等比例缩放<?php include(SimpleImage.php); $image = new SimpleImage(); $image->load(pict...

php实现图片等比例缩放代码

新建文件index.php,需要在统计目录下有个图片为q.jpg(可根据源码进行更改图片的名称) 源代码如下: <?php $filename="q.jpg"; $per=0.3; list($width, $height)=getimagesize($filename); $n_w=$width*$per; $n_h=$height*$per; $new=imagecreatetruecolor($n_w, $n_h); $img=imagecreatefromjpeg($filename); //拷贝部分图像并调整 imagecopyresized($new, $img,0, 0,0, 0,$n_w, $n_h, $width, $height); //图像输出新图片、另存...

如何实现php图片等比例缩放

通过文章给出的源代码可实现针对图片的等比缩放生成缩略图的功能,非常实用的技巧哦。 新建文件index.php,需要在统计目录下有个图片为pic.jpg(可根据源码进行更改图片的名称) 源代码如下: <?php $filename="pic.jpg"; $per=0.3; list($width, $height)=getimagesize($filename); $n_w=$width*$per; $n_h=$height*$per; $new=imagecreatetruecolor($n_w, $n_h); $img=imagecreatefromjpeg($filename); //copy部分图像并调整 imag...

php gd等比例缩放压缩图片函数

本文实例为大家分享了php gd等比例缩放压缩图片函数,供大家参考,具体内容如下 <?php/*** desription 判断是否gif动画* @param sting $image_file图片路径* @return boolean t 是 f 否*/function check_gifcartoon($image_file){$fp = fopen($image_file,rb);$image_head = fread($fp,1024);fclose($fp);return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).NETSCAPE2.0."/",$image_head)?false:true;}/*** desription 压缩图片...

PHP 等比例缩放图片详解及实例代码【图】

直接上代码,imgzip($src,$newwid,$newhei)这个函数带进去的分别是原图片、缩放要求的宽度、缩放的长度。代码都备注了,不懂可以留言哈哈 <?php //压缩图片 缩略图$src= "xiezheng.jpg"; $newwid=640; $newhei= 480; function imgzip($src,$newwid,$newhei){$imgInfo = getimagesize($src);$imgType = image_type_to_extension($imgInfo[2], false);$fun = "imagecreatefrom{$imgType}";//声明图片 打开图片 在内存中$image = $fun...

如何使用php等比例缩放图片

本文介绍了PHP实现图片压缩方法,读者可以根据具体应用参考或加以改进,直接上代码,imgzip($src,$newwid,$newhei)这个函数带进去的分别是原图片、缩放要求的宽度、缩放的长度。 <?php //压缩图片 缩略图 $src= "xiezheng.jpg"; $newwid=640; $newhei= 480; function imgzip($src,$newwid,$newhei){$imgInfo = getimagesize($src);$imgType = image_type_to_extension($imgInfo[2], false);$fun = "imagecreatefrom{$imgType}"; /...

php等比例缩放图片及剪切图片代码分享

php等比例缩放图片及剪切图片代码分享 /*** 图片缩放函数(可设置高度固定,宽度固定或者最大宽高,支持gif/jpg/png三种类型)* Author : Specs** @param string $source_path 源图片* @param int $target_width 目标宽度* @param int $target_height 目标高度* @param string $fixed_orig 锁定宽高(可选参数 width、height或者空值)* @return string*/ function myImageResize($source_path, $target_width = 200, $target_heig...

PHP图片等比例缩放生成缩略图函数分享

代码如下:<?php /* *@im //需要缩放的图片资源 *@filetype //制作的缩略图文件类型 *@dstimW //缩放的图片的宽度 *@dstimH //缩放的图片的高度 *@thumbname //缩略图文件名字function makethumb($im,$dstimW,$dstimH,$thumbname ,$filetype){ //获取im的宽度和高度 $pic_W=imagesx($im); $pic_H=imagesy($im); $arr = array(); swith($filetype){ ...