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

php图片等比例缩放,_PHP教程

php图片等比例缩放,新建文件index.php,需要在统计目录下有个图片为q.jpg(可根据源码进行更改图片的名称) 源代码如下: $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实现图片等比例缩放代码,_PHP教程

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, $hei...

php等比例缩放图片及剪切图片代码分享,_PHP教程

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_pa...

phpgd等比例缩放压缩图片函数,_PHP教程

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:...

php图片等比例缩放函数

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);//图像输出新图片、另存为imagejpeg($new, "q1.jpg");imagedestroy($new);imagedestroy($img);?>

php按最大尺度等比例缩放图片

php 按最大尺寸 等比例缩放图片 $maxWidth = 180;//最大宽度$maxHeight = 125; //最大高度 $iSuofang = $arrPicwh[w]/$arrPicwh[h];//原图的比例$iSuo = $arrPicwh[h]/$arrPicwh[w];if ($arrPicwh[w] > $arrPicwh[h])//判断原图的宽高那个大{$dstW = $maxWidth;$dstH = $maxWidth * $iSuo;}else {$dstH = $maxHeight;$dstW = $maxHeight * $iSuofang;} ?

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){ ...

php等比例缩放图片及剪切图片代码分享_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图片等比例缩放函数的.谁能帮我看看我这个函数怎么用啊?

function resize($srcImage,$toFile,$maxWidth = 100,$maxHeight = 100,$imgQuality=100) { list($width, $height, $type, $attr) = getimagesize($srcImage); if($width 回复内容:function resize($srcImage,$toFile,$maxWidth = 100,$maxHeight = 100,$imgQuality=100) { list($width, $height, $type, $attr) = getimagesize($srcImage); if($width 因为tofile($srcImage,$toFile)第二个参数$toFile自己指定的话存在格式问题...

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){ ...

php实现图片等比例缩放代码_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图片等比例缩放_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部分图像并调整 image...

php等比例缩放图片及剪切图片代码分享_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_heigh...

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

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

php实现图片等比例缩放代码_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); //图像输出新图片、另存...