easyphpthumbnail类可以处理图像和php生成缩略图支持gif、jpg和png。这个类是免费的,基于100%的php,可用于php4(4.3.11以上)和php5,易于使用,并提供了超过60的功能操作:
提供的功能包括:调整大小,裁剪,旋转,翻转,另存为,阴影,水印,文字,边框,锐化,模糊,水波纹,反射镜,透视,动画,置换贴图和更多!
使用简介
1、基本使用 createthumb('gfx/image.jpg');
?>
2、动态显示指定大小图片 thumbsize = 300;
$thumb -> createthumb($dir . 'img.jpg');
?>
3、生成静态多张本地图片 thumbsize = 600;
$thumb -> copyrighttext = 'scutephp.com';
$thumb -> copyrightposition = '50% 90%';
$thumb -> copyrightfonttype = $dir . 'handwriting.ttf';
$thumb -> copyrightfontsize = 30;
$thumb -> copyrighttextcolor = '#ffffff';
$thumb -> chmodlevel = '0755';
$thumb -> thumblocation = $dir_thumbs;
$thumb -> thumbsaveas = 'jpg';
$thumb -> thumbprefix = '120px_thumb_';
$thumb -> createthumb(array($dir . '69.jpg', $dir . '70.jpg'), 'file');
?>
4、图片大小百分比调整及图片旋转 thumbsize = 50;
$thumb -> rotate = 90;//指定度数旋转
//$thumb -> fliphorizontal = true; //水平轴旋转
//$thumb -> flipvertical = true; //垂直轴旋转
$thumb -> percentage = true;
$thumb -> createthumb('gfx/image.jpg');
?>
thumbsize默认是px像素单位,然而要用百分比的话可以设置percentage属性为ture,rotate属性设置顺时针旋转度数。
5、给缩略图增加背景阴影 backgroundcolor = '#d0deee';
$thumb -> shadow = true;
$thumb -> createthumb('gfx/image.jpg');
?>
6、给缩略图增加圆角效果 backgroundcolor = '#d0deee';
$thumb -> clipcorner = array(2,15,0,0,1,1,0);
$thumb -> createthumb('gfx/image.jpg');
?>
clipcorner属性的7个参数含义
[0]: 0=关闭 1=直角 2=圆角
[1]: 裁剪比例
[2]: 随机 - 0=关闭 1=开启
[3]: 左上 - 0=关闭 1=开启
[4]: 左下 - 0=关闭 1=开启
[5]: 右上 - 0=关闭 1=开启
[6]: 右下 - 0=关闭 1=开启
7、给缩略图增加透明效果 backgroundcolor = '#0000ff';
$thumb -> clipcorner = array(2,15,0,1,1,1,1);
$thumb -> maketransparent = array(1,1,'#0000ff',30);
$thumb -> createthumb('gfx/image.jpg');
?>
8、给缩略图增加框架效果 framewidth = 10;
$thumb -> framecolor = '#ffffff';
$thumb -> backgroundcolor = '#d0deee';
$thumb -> shadow = true;
$thumb -> createthumb('gfx/image.jpg');
?>
9、给缩略图增加经典相框效果 framewidth = 10;
$thumb -> framecolor = '#ffffff';
$thumb -> backgroundcolor = '#d0deee';
$thumb -> shadow = true;
$thumb -> binder = true;
$thumb -> binderspacing = 8;
$thumb -> clipcorner = array(2,15,0,1,1,1,0);
$thumb -> createthumb('gfx/image.jpg');
?>
10、给缩略图增加水印效果 thumbsize = 300;
$thumb -> framewidth = 10;
$thumb -> framecolor = '#00000';
$thumb -> backgroundcolor = '#000000';
$thumb -> clipcorner = array(2,15,0,1,1,1,1);
$thumb -> watermarkpng = 'watermark.png';
$thumb -> watermarkposition = '50% 50%';
$thumb -> watermarktransparency = 70;
$thumb -> createthumb('gfx/image.jpg');
?>
11、给缩略图增加短文本及相框 thumbsize = 300;
$thumb -> framewidth = 10;
$thumb -> framecolor = '#00000';
$thumb -> borderpng = 'border.png';
$thumb -> copyrighttext = 'mywebmymail.com';
$thumb -> copyrightposition = '50% 80%';
$thumb -> copyrightfonttype = 'handwriting.ttf';
$thumb -> copyrightfontsize = 30;
$thumb -> copyrighttextcolor = '#ffffff';
$thumb -> createthumb('gfx/image.jpg');
?>
12、缩略图按指定形状裁剪 thumbsize = 300;
$thumb -> borderpng = 'cloud.png';
$thumb -> createthumb('gfx/image.jpg');
?>
13、指定区域裁剪图片 thumbsize = 300;
$thumb -> cropimage = array(2,0,20,20,35,35);
$thumb -> createthumb('gfx/image.jpg');
?>
cropimage属性六个参数说明
[0]: 0=disable 1=enable free crop 2=enable center crop
[1]: 0=percentage 1=pixels
[2]: crop left
[3]: crop right
[4]: crop top
[5]: crop bottom
14、裁剪出旧照片效果 thumbsize = 300;
$thumb -> shadow = true;
$thumb -> backgroundcolor = '#d0deee';
$thumb -> cropimage = array(2,0,20,20,35,35);
$thumb -> ageimage = array(1,10,80);
$thumb -> createthumb('gfx/image.jpg');
?>
15、属性或方法详解a$thumb -> addtext = array()// 对原始图像添加文字
数组有六个参数
[0]: 0=disable 1=enable
[1]: the text to add
[2]: the position of the text '50% 50%' is the center
[3]: path to the ttf font (standard systemfont will be used)
[4]: the fontsize to use
[5]: the copyright text color in web format '#000000'
$thumb -> ageimage = (array) // 应用灰度 array(1,0,0) 或者旧照片效果 array(1,10,80)
数组有六个参数
[0]: boolean 0=disable 1=enable
[1]: add noise 0-100, 0=disable
[2]: sephia depth 0-100, 0=disable (greyscale)
$thumb -> applyfilter = (boolean)// 应用用户自定义3x3过滤器
b$thumb -> backgroundcolor = (string)// web格式的背景 '#ffffff'
$thumb -> binder = (boolean) // 在缩略图左边画一粘合剂
$thumb -> binderspacing = (int) // 以像素为单位的空间
$thumb -> blur = (boolean) // 模糊过滤器
$thumb -> borderpng = (string) // 边框png图片路径
$thumb -> brightness = (array) // 改变图片亮度
数组有两个参数
[0]: boolean 0=disable 1=enable
[1]: brightness -100 to 100
c$thumb -> chmodlevel = (string) // 设置保存图片的权限 '0755'
$thumb -> clipcorner = (array) // 设置圆角 array(2,15,0,1,1,1,0)
数组有七个参数
[0]: 0=disable 1=straight 2=rounded
[1]: percentage of clipping
[2]: clip randomly boolean 0=disable 1=enable
[3]: clip top left boolean 0=disable 1=enable
[4]: clip bottom left boolean 0=disable 1=enable
[5]: clip top right boolean 0=disable 1=enable
[6]: clip bottom right boolean 0=disable 1=enable
$thumb -> colorreplace = (array)// 颜色替换 array(1,'#ffffff','#ff6600',60)
数组有四个参数
[0]: boolean 0=disable 1=enable
[1]: color to replace in web format: '#00ff00'
[2]: replacement color in web format: '#ff0000'
[3]: rgb tolerance 0 - 100
$thumb -> colorize = (array) // 合并图像中的颜色 array(1,0,0,125,0)
数组有五个参数
[0]: boolean 0=disable 1=enable
[1]: red component 0 - 255
[2]: green component 0 - 255
[3]: blue component 0 - 255
[4]: opacity level 0 - 127
$thumb -> contrast = (array)// 改变图像的对比度 array(1,30)
数组有2个参数
[0]: boolean 0=disable 1=enable
[1]: contrast -100 to 100
$thumb -> copyrighttext = (string) // 增加版权文本
$thumb -> copyrightposition = (string) // 版权文本位置 '50% 50%' is the center
$thumb -> copyrightfonttype = (string)// ttf文字字体路径 (standard systemfont will be used)
$thumb -> copyrightfontsize = (int)// 字体大小
$thumb -> copyrighttextcolor = (string) // 文字web格式颜色值 '#000000'
$thumb -> createthumb('imagepath'[,'output']) // 创建或者输出缩略图
函数有两个参数
[string/array]: 原图片完整路径字符串或数组
[string]: output to the 'screen' (standard) or 'file' (option)
$thumb -> createbase64('imagepath')// 以base64数据输出图片
函数有一个参数
[string]: filename for image to convert
$thumb -> createcanvas(i,i,i,s,b)// 创建一个画布图像 - use with createthumb()
函数有五个参数
[int]: canvas width in pixels
[int]: canvas height in pixels
[int]: imagetype php: imagetype_png, imagetype_gif, imagetype_jpeg
[string]: fill color
[boolean]: transparent (boolean)
$thumb -> create_apng(array, string, int)// 创建apng缩略图
函数有三个参数
[array]: array with filenames of png images (frames)
[string]: filename for apng: 'animation.png'
[int]: delay between frames in milliseconds
$thumb -> cropimage = (array)// 裁剪 array(0,0,20,20,20,20)
数组有六个参数
[0]: 0=disable 1=free crop 2=center crop 3=square crop
[1]: 0=percentage 1=pixels
[2]: crop left
[3]: crop right
[4]: crop top
[5]: crop bottom
$thumb -> croprotate = (boolean)// 裁剪图片到同样大小的画布并旋转
d$thumb -> displacementmap = (array) // 变形
数组有7个参数: array(1,'gfx/displacementmap.jpg',0,0,0,50,50)
[0]: 0=disable 1=enable
[1]: path to displacement image (grey #808080 is neutral)
[2]: 0=resize the map to fit the image 1=keep original map size
[3]: x coordinate for map position in px
[4]: y coordinate for map position in px
[5]: x displacement scale in px
[6]: y displacement scale in px
$thumb -> displacementmapthumb = (array) // 缩略图变形
数组有七个参数: array(1,'gfx/displacementmap.jpg',0,0,0,50,50)
[0]: 0=disable 1=enable
[1]: path to displacement image (grey #808080 is neutral)
[2]: 0=resize the map to fit the image 1=keep original map size
[3]: x coordinate for map position in px
[4]: y coordinate for map position in px
[5]: x displacement scale in px
[6]: y displacement scale in px
$thumb -> divisor = (int)// the divisor for the 3x3 filter
e$thumb -> edge = (boolean)// 边缘过滤器
$thumb -> emboss = (boolean) // 浮雕过滤器
f$thumb -> fliphorizontal = (boolean)// 在水平轴翻转图像
$thumb -> flipvertical = (boolean) // 在垂直轴翻转图像
$thumb -> filter = (array)// 3x3矩阵 array(-1,-1,-1,-1,8,-1,-1,-1,-1)
数组有九个参数
[0]: a1,1
[1]: a1,2
[2]: a1,3
[3]: a2,1
[4]: a2,2
[5]: a2,3
[6]: a3,1
[7]: a3,2
[8]: a3,3
$thumb -> framewidth = (int)// 添加缩略图框架(像素)
$thumb -> framecolor = (string) // 框架颜色 '#ffffff'
g$thumb -> gamma = (array) // change the gamma of the image array(1,0.5)
array with 2 values
[0]: boolean 0=disable 1=enable
[1]: gamma correction factor
$thumb -> greyscale = (boolean) // 真彩色灰度转换
i$thumb -> inflate = (boolean) // 允许图片放大
$thumb -> insert_exif('source','exifdata')// 插入二进制数据到jpg图片
function with 2 values
[string]: source filename for jpg image
[string]: binary exif data to insert in jpg image
k$thumb -> keeptransparency = (boolean) //保持原始图像的透明度
l$thumb -> lakefx = (array)// 应用一个湖变形图像 array(1,15,80)
array with 3 values
[0]: boolean 0=disable 1=enable
[1]: density of the waves
[2]: lake area measured from bottom 0 - 100
m$thumb -> maketransparent = (array)// 使图像的透明 array(1,0,'#171915',30)
array with 4 values
[0]: boolean 0=disable 1=enable
[1]: 0=png 1=gif
[2]: replacement color in web format: '#ff0000'
[3]: rgb tolerance 0 - 100
$thumb -> mean = (boolean) // auto-filter: mean
$thumb -> medianfilter = (boolean) // 采用中值滤波器降噪
$thumb -> mirror = (array)// 滤镜效果 array(1,10,70,40,2)
array with 5 values
[0]: boolean 0=disable 1=enable
[1]: mirror transparency gradient starting strength 0 - 100
[2]: mirror transparency gradient ending strength 0 - 100
[3]: mirror area 0 - 100
[4]: mirror 'gap' between original image and reflection in px
$thumb -> mirrorcolor = (string) // the mirror gradient color in web format '#000000'
n$thumb -> negative = (boolean) // create image negative
o$thumb -> offset = (int) // the color offset for the filter
p$thumb -> palette = (array) // change the palette of the image array(1,32)
array with 2 values
[0]: boolean 0=disable 1=enable
[1]: amount of colors for the palette
$thumb -> percentage = (boolean) // use percentage instead of pixels
$thumb -> perspective = (array) // apply a perspective to the image array(1,0,20)
array with 3 values
[0]: boolean 0=disable 1=enable
[1]: direction 0=left 1=right 2=top 3=bottom
[2]: perspective strength 0 - 100
$thumb -> perspectivethumb = (array)// apply a perspective to the thumbnail array(1,0,20)
array with 3 values
[0]: boolean 0=disable 1=enable
[1]: direction 0=left 1=right 2=top 3=bottom
[2]: perspective strength 0 - 100
$thumb -> pixelscramble = (array) // scramble pixels in the image array(1,4,2)
array with 3 values
[0]: boolean 0=disable 1=enable
[1]: pixel range
[2]: repeats (use with care!)
$thumb -> pixelate = (array)// pixelate the image array(1,10)
array with 2 values
[0]: boolean 0=disable 1=enable
[1]: block size in px
$thumb -> polaroid = (boolean) // convert the thumbnail to a polaroid look
$thumb -> polaroidtext = (string) // write a text on the polaroid
$thumb -> polaroidfonttype = (string)// the path to the ttf font
$thumb -> polaroidfontsize = (int) // the fontsize to use
$thumb -> polaroidtextcolor = (string) // the polaroid text color in web format '#000000'
$thumb -> polaroidframecolor = (string)// the polaroid frame color in web format '#ffffff'
q$thumb -> quality = (int)// the output quality of jpg images
r$thumb -> ripplefx = (array) // apply a ripple deformation to the image array(1,5,15,5,5)
array with 5 values
[0]: boolean 0=disable 1=enable
[1]: amount of horizontal waves
[2]: amplitude of horizontal waves in px
[3]: amount of vertical waves
[4]: amplitude of vertical waves in px
$thumb -> rotate = (int)// rotate the image in degrees
$thumb -> read_exif('source') // read exif information from jpg image
function with 1 value, returns exif binary data
[string]: filename for image with exif information
s$thumb -> shadow = (boolean) // add a shadow around the thumbnail
$thumb -> shading = (array)// apply shading to the image array(1,70,80,0)
array with 4 values
[0]: boolean 0=disable 1=enable
[1]: shading strength 0 - 100
[2]: shading area 0 - 100
[3]: shading direction 0=right 1=left 2=top 3=bottom
$thumb -> shadingcolor = (string) // the shading gradient color in web format '#000000'
$thumb -> sharpen = (boolean) // auto-filter: sharpen
$thumb -> square = (boolean) // draw thumbnail on a square canvas
t$thumb -> thumbfilename = (string) // new filename (with extension)
$thumb -> thumbheight = (int) // height of the thumbnail in pixels
$thumb -> thumblocation = (string)// the path to the thumbnail directory
$thumb -> thumbprefix = (string) // the prefix for the thumb filename
$thumb -> thumbsaveas = (string)// convert the thumbnail to a different format, jpg, gif or png
$thumb -> thumbsize = (int)// thumbnailsize in pixels for width (landscape) or height (portrait)
$thumb -> thumbwidth = (int) // width of the thumbnail in pixels
$thumb -> twirlfx = (array) // apply a twirl deformation to the image array(1,20,0)
array with 3 values
[0]: boolean 0=disable 1=enable
[1]: effect strength 0 to 100
[2]: direction of twirl 0=clockwise 1=anti-clockwise
w$thumb -> waterdropfx = (array)// apply a waterdrop deformation to the image array(1,1.2,400,40)
array with 4 values
[0]: boolean 0=disable 1=enable
[1]: amplitude in px
[2]: radius in px
[3]: wavelength in px
$thumb -> watermarkpng = (string) // the path to the watermark png image
$thumb -> watermarkposition = (string) // the position of the watermark '50% 50%' is the center
$thumb -> watermarktransparency = (int)// the transparency of the watermark 0 to 100
$thumb -> wipe_exif('source','destination')// delete exif information from jpg image
function with 2 values
[string]: source filename for image with exif information
[string]: filename for image without exif information
项目地址:http://www.mywebmymail.com/?q=content/easyphpthumbnail-class
