【兼容性最强的PHP生成缩略图的函数代码(修改版)】教程文章相关的互联网学习教程文章

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

本文实例讲述了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动态生成缩略图并输出显示的方法。分享给大家供大家参考。具体如下: 调用方法: <img src="thumbs.php?filename=photo.jpg&width=100&height=100">此代码可以为大图片动态生成缩略图显示,图片在内存中生成,不在硬盘生成真实文件 thumbs.php文件如下: <?php $filename= $_GET[filename]; $width = $_GET[width]; $height = $_GET[height]; $path="http://localhost/images/"; //finish in "/" // Content type...

php使用GD库创建图片缩略图的方法

本文实例讲述了php使用GD库创建图片缩略图的方法。分享给大家供大家参考。具体分析如下: 上传页面的静态html代码: <html> <head> <title>文件上传</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> </head> <H1>文件上传</H1> <form enctype="multipart/form-data" action="Upload.php" method="post"> <input name="upfile" type="file"><BR> <input type="submit" value="Submit"> </...

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简单生成缩略图相册的方法

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

WordPress中调试缩略图的相关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 Imagick完美实现图片裁切、生成缩略图、添加水印

本文实例讲解了PHP使用Imagick 裁切、生成缩略图、添加水印自动检测和处理,支持gif,分享给大家供大家参考,具体内容如下 调用方式:include imagick.class.php; $image = new lib_image_imagick(); $image->open(a.gif); $image->resize_to(100, 100, scale_fill); $image->add_text(1024i.com, 10, 20); $image->add_watermark(1024i.gif, 10, 50); $image->save_to(x.gif); imagick.class.php<?php /* @版本日期...

php实现常见图片格式的水印和缩略图制作(面向对象)

本文实例为大家分享了php水印和缩略图制作代码,使用面向对象的方法来实现常见图片格式jpg,png,gif的水印和缩略图的制作,供大家参考,具体内容如下 <?php header(Content-Type:text/html;charset=utf-8); /* * To change this license header, choose License Headers in Project Properties.* To change this template file, choose Tools | Templates* and open the template in the editor.*/ //给图片添加水印 Class Water{...

php实现在新浪云中使用imagick生成缩略图并上传的方法

本文实例讲述了php实现在新浪云中使用imagick生成缩略图并上传的方法。分享给大家供大家参考,具体如下: imagick是一款php的图像处理插件了我们可以使用imagick来进行许多的一些操作了,下面我们来看一篇关于php在新浪云中使用imagick的方法吧,具体的细节如下。 php在新浪云中使用imagick生成缩略图并上传到Storage的方法 <?php //缩略图$tmpFile =http://XXXX.com/original.jpg ;list($width, $height) = getimagesize($tmpFile...

php实现水印文字和缩略图的方法示例

本文实例讲述了php实现水印文字和缩略图的方法。分享给大家供大家参考,具体如下: <?php$im = xiatian.jpg;$im2 = winter3.jpg;$img = getImage($im);$bimg = getImage($im2);//$image = getimagesize($im);//print_r($image);//Array ( [0] => 150 width/*[1] => 150 height[2] => 3 图片类型[3] => width="150" height="150"[bits] => 8[mime] => image/png )*///图片复制组合------$bimg----imagecopy($bimg, $img, 300, 4, 0,...

PHP生成图片缩略图类示例

本文实例讲述了PHP生成图片缩略图类。分享给大家供大家参考,具体如下: class App_image_helper {protected $imgFileName;protected $imgWidth;protected $imgHeight;protected $imgMime;protected $imgResource;static $imgMineList= array(jpeg => image/jpeg,gif => image/gif,png => image/png,wbmp => image/wbmp,);/*** 根据文件名,初始化图片,* 计算出给定图片的宽、高、图片类型,并获取图片的资源保存到内存,便于下次...

php生成图片缩略图功能示例

本文实例讲述了php生成图片缩略图功能。分享给大家供大家参考,具体如下: 完整代码如下(为方便阅读,代码使用http://tools.jb51.net/code/phpformat进行了格式化处理): <?php /** Created on 2011-3-18** To change the template for this generated file go to* Window - Preferences - PHPeclipse - PHP - Code Templates */ /*构造函数-生成缩略图+水印,参数说明: $srcFile-图片文件名, $dstFile-另存文件名, $markwords-水...

PHP基于正则批量替换Img中src内容实现获取缩略图的功能示例

本文实例讲述了PHP基于正则批量替换Img中src内容实现获取缩略图的功能。分享给大家供大家参考,具体如下: 这里PHP用正则批量替换Img中src内容,实现获取图片路径缩略图的功能 网上很多正则表达式只能获取或者替换一个img的src内容,或者只能替换固定的字符串,要动态替换多个图片内容的试了几个小时才解决。 /** * 图片地址替换成压缩URL * @param string $content 内容 * @param string $suffix 后缀 */ function get_img_thumb_u...

PHP基于GD库实现的生成图片缩略图函数示例

本文实例讲述了PHP基于GD库实现的生成图片缩略图函数。分享给大家供大家参考,具体如下: <?php /*** 生成缩略图函数(支持图片格式:gif、jpeg、png和bmp)* @author ruxing.li* @param string $src 源图片路径* @param int $width 缩略图宽度(只指定高度时进行等比缩放)* @param int $width 缩略图高度(只指定宽度时进行等比缩放)* @param string $filename 保存路径(不指定时直接输出到浏览器)* @return bool*/ fun...