【求PHP生成缩略图的功能,该怎么解决】教程文章相关的互联网学习教程文章

基于GD2图形库的PHP生成图片缩略图类代码分享_php技巧

要使用PHP生成图片缩略图,要保证你的PHP服务器安装了GD2图形库 使用一个类生成图片的缩略图 1.使用方法 $resizeimage = new resizeimage("图片源文件地址", "200", "100", "0","缩略图地址"); //就只用上面的一句话,就能生成缩略图,其中,源文件和缩略图地址可以相同,200,100分别代表宽和高 2. 缩略图类代码 //使用如下类就可以生成图片缩略图,<?php class resizeimage {//图片类型var $type;//实际宽度var $width;//实际高度var $h...

Thinkphp调用Image类生成缩略图的方法_php实例

本文实例讲述了Thinkphp调用Image类生成缩略图的方法。分享给大家供大家参考。具体分析如下: Thinkphp的Image类 在ThinkPHP/Extend/Library/ORG/Util/Image.class.php中。 调用方法如下: import("ORG.Util.Image"); $Img = new Image();//实例化图片类对象 $image_path = ./图片路径; //若当前php文件在Thinkphp的中APP_PATH路径中 //./就是index.php的上一级文件。 //因为APP_PATH是通过index.php定义和加载的。 $image_info = ...

php实现从上传文件创建缩略图的方法_php技巧

本文实例讲述了php实现从上传文件创建缩略图的方法。分享给大家供大家参考。具体实现方法如下: <?php if ($_REQUEST[action]=="add"){ $userfile = $HTTP_POST_FILES[photo][tmp_name]; $userfile_name = $HTTP_POST_FILES[photo][name]; $userfile_size = $HTTP_POST_FILES[photo][size]; $userfile_type = $HTTP_POST_FILES[photo][type]; ///////////////////////// //GET-DECLARE DIMENSIONS // $dimension = getimagesize($...

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

php使用GD创建保持宽高比缩略图的方法_php技巧

本文实例讲述了php使用GD创建保持宽高比缩略图的方法。分享给大家供大家参考。具体如下: /** * Create a thumbnail image from $inputFileName no taller or wider than * $maxSize. Returns the new image resource or false on error. * Author: mthorn.net */ function thumbnail($inputFileName, $maxSize = 100) {$info = getimagesize($inputFileName);$type = isset($info[type]) ? $info[type] : $info[2];// Check suppo...

php动态生成缩略图并输出显示的方法_php技巧【图】

本文实例讲述了php动态生成缩略图并输出显示的方法。分享给大家供大家参考。具体如下: 调用方法: 此代码可以为大图片动态生成缩略图显示,图片在内存中生成,不在硬盘生成真实文件 thumbs.php文件如下: <?php $filename= $_GET[filename]; $width = $_GET[width]; $height = $_GET[height]; $path="http://localhost/images/"; //finish in "/" // Content type header(Content-type: image/jpeg); // Get new dimensions list(...

php使用GD库创建图片缩略图的方法_php技巧【图】

本文实例讲述了php使用GD库创建图片缩略图的方法。分享给大家供大家参考。具体分析如下: 上传页面的静态html代码:文件上传 文件上传 相应的Upload.php文件代码: <?php $uploadfile = "upfiles/".$_FILES[upfile][name]; //上传后文件所在的文件名和路径 = "upfiles/small_".$_FILES[upfile][name]; //上传后缩略图文件所在的文件名和路径 if($_FILES[upfile][type] != "image/pjpeg") { echo "文件类型错误"; //输出错误信息...

PHP批量生成图片缩略图的方法_php技巧

本文实例讲述了PHP批量生成图片缩略图的方法。分享给大家供大家参考。具体如下: <?php //用PHP批量生成图片缩略图function mkdirs($dirname,$mode=0777)//创建目录(目录, [模式]){if(!is_dir($dirname)){mkdirs($dirname,$mode); //如果目录不存在,递归建立return mkdir($dirname,$mode);}return true;}function savefile($filename,$content=)//保存文件(文件, [内容]){if(function_exists(file_put_contents)){file_put_con...

PHP获取Exif缩略图的方法

本文实例讲述了PHP获取Exif缩略图的方法。分享给大家供大家参考。具体实现方法如下:// file to read $file = test.jpg; $image = exif_thumbnail($file, $width, $height, $type); // width, height and type get filled with data // after calling "exif_thumbnail" if ($image) {// send header and image data to the browser:header(Content-type: .image_type_to_mime_type($type));print $image; } else {// there is no ...

PHP简单生成缩略图相册的方法_php技巧【图】

本文实例讲述了PHP简单生成缩略图相册的方法。分享给大家供大家参考。具体如下: <?php /** written by mot* 根目录下自己新建image thumb目录* */ class thumb{private $src;private $source;private $s_width;private $s_height;private $dest;private $d_height;private $d_width;private $name;public function thumb($image_path,$rate = 0.5){$this->src = $image_path;$this->source = imagecreatefromjpeg($image_path);$s...

php生成高清缩略图实例详解_php技巧

本文实例讲述了php生成高清缩略图的方法。分享给大家供大家参考,具体如下: 在使用php的函数生成缩略图的使用,缩略图很多情况下都会失真,这个时候需要有一些对应的解决方法。 1.用imagecreatetruecolor和imageCopyreSampled函数分别取代imagecreate和imagecopyresized 2.给imagejpeg的第三个参数带上100(例:imagejpeg($ni,$toFile,100)) 下面是具体的函数 function CreateSmallImage( $OldImagePath, $NewImagePath, $NewWidth=...

php上传图片生成缩略图(GD库)_php技巧【图】

首先来一段简单的php上传图片生成缩略图的详细代码,分享给大家供大家参考,具体内容如下 <?php function createThumbnail($imageDirectory, $imageName, $thumbDirectory, $thumbWidth, $quality){ $details = getimagesize("$imageDirectory/$imageName") or die(Please only upload images.); $type = preg_replace(@^.+(?<=/)(.+)$@, $1, $details[mime]); eval($srcImg = imagecreatefrom.$type.("$imageDirectory/$imageName...

WordPress中调试缩略图的相关PHP函数使用解析_php技巧

the_post_thumbnail the_post_thumbnail 在 WordPress 中主要用来打印文章中设定的缩略图,而 get_the_post_thumbnail 函数可以将你需要的 HTML 代码以字符串的形式返回。 the_post_thumbnail 函数的使用the_post_thumbnail( $size , $attr) 函数参数 $size 是指你想要的缩略图类型 默认是 ‘post-thumbnail 也就是特色图像$attr 图像img标签中的属性设置。the_post_thumbnail 函数声明/*** Display Post Thumbnail.** @since 2.9....

php使用timthumb生成缩略图的方法_php技巧【图】

本文实例讲述了php使用timthumb生成缩略图的方法。分享给大家供大家参考,具体如下: 生成缩列图有二种方式: 一、提前生成好,供调用 缩列图常规做法是,开始根据网站中的图片规格,要生成多少种缩列图,图片上传过程中就会生成缩列,供不同需求去调用。像这种方法有一点不好就是,如果增加图片规格以后,以前上传的图片没有该规格的,还要重新生成。 二、调用的时候在生成缩列图。这也是我写这篇文章原因。 推荐一个timthumb,个...

PHP实现原比例生成缩略图的方法_php技巧

本文实例讲述了PHP实现原比例生成缩略图的方法。分享给大家供大家参考,具体如下: <?php $image = "jiequ.jpg"; // 原图 $imgstream = file_get_contents($image); $im = imagecreatefromstring($imgstream); $x = imagesx($im);//获取图片的宽 $y = imagesy($im);//获取图片的高 // 缩略后的大小 $xx = 140; $yy = 200; if($x>$y){ //图片宽大于高$sx = abs(($y-$x)/2);$sy = 0;$thumbw = $y;$thumbh = $y; } else { //图片高大于...

功能 - 相关标签