【php生成缩略图填充白边(等比缩略图方案)】教程文章相关的互联网学习教程文章

PHP等比例缩放图片生成缩略图函数的例子

/**@im //需要缩放的图片资源*@filetype //制作的缩略图文件类型*@dstimW //缩放的图片的宽度*@dstimH //缩放的图片的高度*@thumbname //缩略图文件名字// WWW.JBXUE.COMfunction makethumb($im,$dstimW,$dstimH,$thumbname ,$filetype){//获取im的宽度和高度$pic_W=imagesx($im);$pic_H=imagesy($im);$arr = array();swith($filetype){case 'jpg':$arr[$filetype]="imagejpeg";break;case 'png';$arr[$filetype]="imagepng";br...

Codeigniter多文件上传与缩略图实现代码

<?phpclass Upload extends Controller { function go() { if(isset($_POST[go])) { //初始化 $config[upload_path] = album/source; $config[allowed_types] = gif|jpg|png|bmp|jpeg; $config[encrypt_name] = TRUE; $config[remove_spaces] = TRUE; $config[max_size] = 0; $config[max_width] = 0; $config[max_height] = 0; $this->load->library(upload, $config); ...

php获取远程图片url生成缩略图的方法

/** **函数:调整图片尺寸或生成缩略图 *返回:True/False *参数:* $Image 需要调整的图片(含路径) * $Dw=450 调整时最大宽度;缩略图时的绝对宽度 * $Dh=450 调整时最大高度;缩略图时的绝对高度 * $Type=1 1,调整尺寸; 2,生成缩略图 */ bbs.it-home.org$phtypes=array('img/gif', 'img/jpg', 'img/jpeg', 'img/bmp', 'img/pjpeg', 'img/x-png'); function compressImg($Image,$Dw,$Dh,$Type){ IF(!file_exists...

php支持imagemagick与gd库缩略图生成类

分享一个php实现的缩略图类,支持imagemagick及gd库两种处理的缩略图生成类,功能包括按区域裁剪图片、添加水印、包括水印功能、透明度等,需要的朋友参考下。 php实现同时支持imagemagick及gd库的缩略图生成类与用法。 一、功能: 1、按比例缩小/放大 2、填充背景色 3、按区域裁剪 4、添加水印,包括水印的位置,透明度等 使用imagemagick/GD库实现,imagemagick地址:www.imagemagick.org 先安装imagemagick,安装方法: http://b...

php根据url自动生成缩略图实现代码

<IfModule mod_rewrite.c> RewriteEngine On # -s (is regular file, with size) # -l (is symbolic link) # -d (is directory) # ornext|OR (or next condition) # nocase|NC (no case) # last|L (last rule) RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ createthumb.php?path=%{REQUEST_URI} [NC,L] ...

php图片缩略图生成代码(支持png透明)【图】

/* * desc: Resize Image(png, jpg, gif)*/class ResizeImage {//图片类型private $type;//实际宽度private $width;//实际高度private $height;//改变后的宽度private $resize_width;//改变后的高度private $resize_height;//是否裁图private $cut;//源图象private $srcimg;//目标图象地址private $dstimg;//临时创建的图象private $im;function __construct($imgPath, $width, $height, $isCut, $savePath) {$this->srcimg = $img...

php等比缩放上传图片缩略图的代码

/** * * *等比缩放 * @param unknown_type $srcImage 源图片路径 * @param unknown_type $toFile 目标图片路径 * @param unknown_type $maxWidth 最大宽 * @param unknown_type $maxHeight 最大高 * @param unknown_type $imgQuality 图片质量 * @return unknown */ function resize($srcImage,$toFile,$maxWidth = 100,$maxHeight = 100,$imgQuality=100) { list($width, $height, $type, $attr) = geti...

php缩略图与图片水印类(等比缩放图片大小)

<?php/** * * 图像处理类 * @author FC_LAMP * @internal功能包含:水印,缩略图 */class Img{ //图片格式 private $exts = array (jpg, jpeg, gif, bmp, png ); /** * * * @throws Exception */ public function __construct() { if (! function_exists ( gd_info )) { throw new Exception ( 加载GD库失败! ); } } /** * * 裁剪压缩 * @param $src_img 图片 * @param $save_img 生成后的图片 * @param $option...

php缩略图代码,imagecopyresampled函数生成缩略图

function CreateImage($SrcImageUrl, $DirImageUrl, $Width, $Height){$img;$srcw;$new_width;$srch;$new_height;// 图片类型$type = substr(strrchr($SrcImageUrl, "."), 1);// 初始化图像 if($type == "jpg") $img = imagecreatefromjpeg($SrcImageUrl); if($type == "gif") $img = imagecreatefromgif($SrcImageUrl); if($type == "png") $img = imagecreatefrompng($SrcImageUrl);$srcw = imagesx($img);$srch = imagesy($img)...

php缩略图:php上传文件时创建缩略图的方法

php缩略图创建的例子,在php文件上传同时创建缩略图的代码,通过本例可以学习php gd库生成缩略图的方法及相关技巧。 php上传文件创建缩略图 php文件上传与及图片操作技巧

PHP按最大宽高缩略图片函数代码

很简单的按照最大宽高来缩略图片的代码,方便新手和懒得自己写的人function thumb($imagefile, $maxwidth, $maxheight) { $dim = getimagesize($imagefile); $width = $dim[0]; //原图宽度 $height = $dim[1]; //原图高度 $original = imagecreatefromjpeg($imagefile); $thcrown = $maxwidth/$maxheight; //缩略图最大宽度与最大高度比 $crown = $width/...

PHP创建图片缩略图

<?php/** * 上传图片生成缩略图 * * 需要GD2库的支持 * * 初始化时需要参数new thumbnails(需要缩略的图片的原始地址,缩略图的宽度,缩略图的高度,(可选参数)缩略图的保存路径); * 如果最后一个参数不指定,那么缩略图就默认保存在原始图片的所在目录里的small文件夹里, * 如果不存在small文件夹,则会自动创建small文件夹 * * 初始化之后需要调用方法produce创建缩略图 * $thumbnails = new thumbnails(....); * $thumbnails...

简单的PHP生成缩略图函数

简单的生成缩略图函数,支持图片格式:gif、jpeg、png和bmp,支持缩放到固定大小或进行等比缩放,支持直接输入到浏览器或保存到文件。<?php/** * 简单的生成缩略图函数(支持图片格式:gif、jpeg、png和bmp) * @author xiaoshuoit@163.com * @param string $src 源图片路径 * @param int $width 缩略图宽度(只指定高度时进行等比缩放) * @param int $width 缩略图高度(只指定宽度时进行等比缩放) * @param string $filen...

PHP添加水印&amp;比例缩略图&amp;固定高度&amp;固定宽度类

PHP 添加水印 & 比例缩略图 & 固定高度 & 固定宽度 类。使用foreach 循环处理的时候,需要 sleep 设定一个时间 或者 按照处理后的返回值 ,否则处理不完。下载: http://pan.baidu.com/s/1ntKAfFF//文件名:image_process.class.php<?phpclass Image_process{ public $source;//原图 public $source_width;//宽 public $source_height;//高 public $source_type_id; public $orign_name; public $orign_dirname;...

PHP图片上传类;支持水印-日期文件夹-生成缩略图,支持多文件上传

可以用{Y}{m}{n}来变成现在的日期 set_dir(dirname(__FILE__)./upload/,{y}/{m}); //保存路径,支持{y}{m}{d}这几个选项 $up->set_thumb(100,80); //缩略图大小设置.单位为像素 $up->set_watermark(dirname(__FILE__)./jblog/images/watermark.png,6,90); //水印设置 $fs = $up->execute(); //开始执行 var_dump($fs); //测试用 查看类的情况} ?> /////视图表单--------- ...