【生成缩略图】教程文章相关的互联网学习教程文章

PHP如何生成自适应大小的缩略图

生成缩略图的php类,新建一个文件叫做 thumbnailimage.php,文件名最好不要用大写。define ( 'MAX_IMG_SIZE', 100000 );// Supported image typesdefine ( 'THUMB_JPEG', 'image/jpeg' );define ( 'THUMB_PNG', 'image/png' );define ( 'THUMB_GIF', 'image/gif' );// Interlacing modesdefine ( 'INTERLACE_OFF', 0 );define ( 'INTERLACE_ON', 1 );// Output modesdefine ( 'STDOUT', '' );// Empty constantsdefine ( 'NO_LOGO'...

php生成缩略图的代码(兼容性好)

PHP生成缩略图的代码很多,不过能完全兼容gd1.6和gd2.x,并能保证缩图清晰性的代码几乎没有,以下代码可以实现较好的兼容性。分享出来,供大家学习参考。<?phpfunction ImageResize($srcFile,$toW,$toH,$toFile=""){ if($toFile==""){ $toFile = $srcFile; } $info = ""; $data = GetImageSize($srcFile,$info); switch ($data[2]) { case 1: if(!function_exists("imagecreatefromgif")){ echo "你的GD库...

又一个生成图片缩略图的函数

function photoThumb($p_thumb_file, $p_photo_file, $p_max_size, $p_quality = 75) { $pic = @imagecreatefromjpeg($p_photo_file); if ($pic) { $thumb = @imagecreatetruecolor ($p_max_size, $p_max_size) or die ("Can't create Image!"); $width = imagesx($pic); $height = imagesy($pic); if ($width $twidth = $p_max_size; $theight = $twidth * $...

一个创建图片缩略图的函数

/** * 创建图片缩略图,成功返回真 * * @param string $cat 目录 * @param string $oldname 原图文件名 * @param string $newname 新图文件名 * @param int $width 缩略图宽 * @param int $height 缩略图高 * @return */function thumb($cat,$oldname,$newname,$width=160,$height=120){ $srcFile = $cat. "/" .$oldname; $data = getimagesize($srcFile); $dscFile = $cat. "/". $newname; switc...

phpGD库上传图片并创建缩略图的代码【图】

图片上传-bbs.it-home.org文件上传(只允许上传jpg类型图片)2、处理页面 upload_img.php //上传图片保存地址 $uploadfile = "upfiles/".$_FILES['upfile']['name']; //缩略图保存地址 https://www.gxlcms.com/$smallfile = "upfiles/small_".$_FILES['upfile']['name']; if($_FILES['upfile']['type'] != "image/jpeg") { echo '文件类型错误'; } else { move_uploaded_file($_FILES['upfile']['tmp_...

php上传文件并生成缩略图的函数

php 上传文件并生成缩略图的代码,分为单文件与多文件上传,并可以生成缩略图,确实不错,建议大家参考学习下。完整代码如下。* ******************************************************/ function UpLoadFileAll($input='UpPic', $path='upload', $ftype='jpg,gif,png', $fsize=2){ $fileInfo = $_FILES[$input]; //文件信息 if(strrpos($path, '/') $error){if ($error == 0) { $name = $file...

php根据请求生成缩略图片保存到Linux图片服务器的代码

/** * 缩略图片 Linux图片服务器 * edit bbs.it-home.org*/ $picID=$_GET['imgID']; $picTypes=".".$_GET['imgType']; $picWidth=$_GET['ImgWidth']; if($picID!="") { //请求的是小图 if($picWidth>0){ //如果小图存在 if(file_exists($picID."_".$picWidth.$picTypes)) { outputImg($picID."_".$picWidth.$picTy...

php缩略图代码,实现满窗格等比例缩小【图】

/*** 等比例缩小的缩略图* edit bbs.it-home.org*/ function thumbs($FileName,$SaveTo,$SetW,$SetH){ $IMGInfo= getimagesize($FileName); if(!$IMGInfo) return false; if($IMGInfo[mime]== "image/pjpeg" || $IMGInfo[mime]=="image/jpeg"){ $ThisPhoto= imagecreatefromjpeg($FileName); }elseif($IMGInfo[mime]== "image/x-png" || $IMGInfo[mime]== "image/png"){ ...

php缩略图类(附调用示例)

本文介绍下,php实现的一个缩略图类,支持加载图片文件与加载图片字符串,按比例拉伸等,代码后面有调用示例供参考。分享个php缩略图类,可以实现如下的功能: 1,支持加载图片文件和加载图片字符串 2,可以将缩略图输出到浏览器和保持缩略图文件 3,支持gif,png,jpeg类型的缩略 4,可以设定是否按比例来拉伸 代码如下:maxWidth = $maxWidth;$this->maxHeight = $maxHeight;$this->scale = $scale;$this->inflate = $inflate;$t...

php图片文件上传类(可自动生成缩略图)

分享一个php图片上传类,且可以自动生成缩略图,有需要的朋友,可以作个参考,希望可以对您有用。php实现的图片文件上传类,代码:savefile(); # 保存方法 并返回保存路径附带文件名;@ echo MakeBuild($BuildFile,$newFile,$File_width); 生成指定文件的缩略图; $myupload->MakeBuild("images/a.jpg","news/b.jpg","100"); */class upfileClass { var $upfile, $upfile_name, $upfile_size;var $new_upfile_name; # 上传后的文件...

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

/** 缩略图生成类,支持imagemagick及gd库两种处理 * Date: 2013-07-15 * Author: fdipzone * Ver: 1.2 * edit: bbs.it-home.org* Func: * public set_config: 设置参数 * public create_thumb: 生成缩略图 * private fit: 缩略图片 * private crop: 裁剪图片 * private gd_fit: GD库缩略图片 * private gd_crop: GD库裁剪图片 * private get_size: 获取要转换的size * private get_crop_offset: ...

php根据url自动生成缩略图(附源码)

sudo a2enmod rewrite 2,.htaccess文件的内容:<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] Rew...

phpGD库生成高质量缩略图(示例)

$FILENAME="image.thumb"; // 生成图片的宽度 $RESIZEWIDTH=400; // 生成图片的高度 $RESIZEHEIGHT=400;function ResizeImage($im,$maxwidth,$maxheight,$name){ $width = imagesx($im); $height = imagesy($im); if(($maxwidth && $width > $maxwidth) || ($maxheight && $height > $maxheight)){ if($maxwidth && $width > $maxwidth){ $widthratio = $maxwidth/$width; $RESIZEWIDTH=true; } if($maxheight && $height > $maxhe...

php缩略图填充白边的示例代码

//源图的路径,可以是本地文件,也可以是远程图片$src_path = 1.jpg;//最终保存图片的宽$width = 160;//最终保存图片的高$height = 120;//源图对象$src_image = imagecreatefromstring(file_get_contents($src_path));$src_width = imagesx($src_image);$src_height = imagesy($src_image);//生成等比例的缩略图$tmp_image_width = 0;$tmp_image_height = 0;if ($src_width / $src_height >= $width / $height) { $tmp_image_wi...

phpGD库生成缩略图的例子

<?php header("content-type:text/html;charset=gbk"); ini_set("date.timezone","Asia/chong"); //判断文件是否为空 if(empty($_FILES)){ echo"上传文件过大"; exit; } //判断文件上传是否有错误 if($_FILES[pic][error]){ echo "上传文件"; exit; } //判断文件类型是否非法获取文件后缀 $allowtype=array("jpg","png","jpeg","gif"); $a=explode(.,$_FILES[pic][name]); $index=count($a)-1; $ex=strtolower($a[$index]); if(!in...