非常强大的图象处理函数iMagick

Publish: February 8, 2012 Category: PHP No Comments

 

imagick是连接PHP和ImageMagick的通道。

ImageMagick是Linux下非常强大的图象处理函数。
特点比如:
1、除了对图象的基本出来外,还可以对图象进行滤镜处理。
2、支持80多种图片格式(包括GIF)。
3、生成的图片同分辨率情况下质量好于GD(JPG)
4、生成的图片同分辨率情况下文件大小比GD小一倍以上(JPG)
5、太多了

imagick没有文档,有的函数没有写说明,我补充了一份。

PHP iMagick Function Document

PHP 4.3.8 imageMagick 6.0.0 iMagick 0.9.9

导读:iMagick的作者并未告诉大家可以使用那些函数以及方法,这些函数和方法都是从source文件中的定义找到。作者摸索测试。请大家在有example的代码情况下做测试,不然很难用明白。


Function Description
图片构造类 image_handle = imagick_readimage([image file]) 读取图片到handle
  bool = imagick_writeimage([source image handle],[new name & filetype]) 写图片
  UN KNOW USE = imagick_writeimages  
  new_handle = imagick_clonehandle([image handle]) 复制出新句柄
  image_handle = imagick_image2blob([blob handle]) 将数据流数据转换成为image数据
  imagick_blob2image 与image2blob相反
  image_handle = imagick_getcanvas([color],[canvas width],[canvas height]) 创建一个画布
  UN KNOW USE = imagick_newimagelist  
错误句柄类 bool = imagick_iserror([image handle]) 最后一次执行是否成功
  rason_string = imagick_failedreason([image handle]) 如果执行iImagick函数返回假将可以从本函数抛出失败
  desc_string = imagick_faileddescription([image handle]) 显示抛出的异常描述
  error_string = imagick_error([image handle]) 返回错误内容
获取图片信息类 image_width = imagick_getwidth([image handle]) 获得图片宽度
  image_height = imagick_getheight([image handle]) 获得图片高度
  mime_string = imagick_getmimetype([image handle]) 获得图片MIME类型
  depth_int = imagick_getimagedepth([image handle]) 获得图片DEPTH值
  colors_num = imagick_getnumbercolors([image handle]) 获得图片颜色数量
  bool = imagick_isgrayimage([image handle]) 是否会度图片
  bool = imagick_ismonochromeimage([image handle]) 是否单色图片
  bool = imagick_isopaqueimage([image handle]) 是否不透明图片
  bool = imagick_ispaletteimage([image handle]) 是否彩色图片
  image_type = imagick_getimagetype([image handle]) 获得图片颜色值
  bool = imagick_isimagesequal([image handle1],([image handle2])) 图片是否相同
  magick_type = imagick_getmagick([image handle]) 获得图片类型
  int = imagick_getcolorspace([image handle])  
图片转换类 bool = imagick_convert([image handle],[new type]) 将图片数据转换成为指定格式
  bool = imagick_setcompressiontype([image handle],[compression type]) 指定图片的压缩方式
  bool = imagick_setcompressionquality([image handle],[quality value]) 指定图片的压缩质量
尺寸调整类 bool = imagick_resize([image handle],[new width],[new height],[filter type],[blur],[geometry]) 改变图片尺寸
  UN KNOW USE imagick_magnify  
  UN KNOW USE imagick_minify  
  bool = imagick_scale([image handle],[new width],[new height],[geometry]) 按照指定比例缩小图片
  bool = imagick_sample([image handle],[new width],[new height],[geometry]) 缩小产生样本图片
  bool = imagick_zoom([image handle],[new width],[new height],[geometry]) 放大图片
字体设置类 bool = imagick_setfontsize([image handle],[size]) 设置字体大小
  UN KNOW USE imagick_setfontstyle  
  bool = imagick_setfontface([image handle],[Font Name]) 设置采用的字体
绘图类 bool = imagick_begindraw([image handle]) 开始在一个image上绘画
  bool = imagick_drawannotation([image handle],[x],[y],[text]) 在image上的x y开始画一些文字符号
  bool = imagick_drawrectangle([image handle],[up x],[up y],[low x],[low y]) 画一个矩形
  bool = imagick_drawellipse([image handle],[starting x],[starting y],[ending x],[ending y],[start rotation in degrees],[end rotation in degrees]) 画一个椭圆形
  bool = imagick_drawarc([image handle],[origin x],[origin y],[ x radius],[ y radius],[ start rotation in degrees],[ end rotation in degrees]) 画一个弧形
  bool = imagick_drawcircle([image handle],[origin x],[origin y],[perimater x],[perimater y]) 画一个圆
  bool = imagick_drawline([image handle],[starting x],[starting y],[ending x],[ending y]) 画一条线
  bool = imagick_drawpoint([image handle],[x coordinate ],[y coordinate ]) 画一个点
  bool = imagick_setfillcolor([image handle],[color vlaue]) 设置填充颜色
  bool = imagick_setfillopacity([image handle],[opactiy]) 设置不透明度
质量增强类 bool = imagick_rotate([image handle],[degrees]) 设置旋转图片的角度
  bool = imagick_shear([image handle],[x coordinate],[y coordinate]) 旋转剪切
  bool = imagick_contrast([image handle],[contrast value]) 提高或降低图象对比度
  bool = imagick_equalize([image handle]) 色彩均匀化
  bool = imagick_gamma([image handle],[gamma value 0.8 - 2.3]) 图象GAMMA调整
  bool = imagick_level([image handle],[gamma value 0.8 - 2.3]) 图象GAMMA调整
  bool = imagick_modulate([image handle],[modulate]) 调整亮度,饱和度,色彩
  bool = imagick_negate([image handle],[gray scale value]) 反色图片
  bool = imagick_normalize([image handle]) 规格化图片
图片装饰类 bool = imagick_border([image handle],[ x starting position of border ],[y starting position of border ],[width of border],[height of border]) 在图片上化一个边框
  UN KNOW USE imagick_frame  
  bool = imagick_raise([image handle],[ x starting position of border ],[ y starting position of border ],[ width of border],[ height of border],[raise non-zero]) 浮雕效果
效率滤镜类 bool = imagick_charcoal([image handle],[the radius of pixel neighborhood],[the standard deviation of the Gaussian, in pixels]) 碳笔
  bool = imagick_implode([image handle],[define the extent of the implosion]) 内曝效果
  bool = imagick_oilpaint([image handle],[the radius of the circular
neighborhood])
油画效果
  bool = imagick_solarize([image handle],[define the extent of solarization - this value is between 0 and MaxRGB]) 反转曝光
  bool = imagick_swirl([image handle],[define the tightness of the swirling
effect ])
旋涡
  bool = imagick_wave([image handle],[the amplitude of the wave],[the frequency of the wave]) 水波纹
图片滤镜类 bool = imagick_blur([image handle],[the radius of the Gaussian, in
pixels, not counter the center pixel],[the standard deviation of the
Gaussian, in pixels])
模糊
  bool = imagick_despeckle([image handle]) 平滑聚焦图象
  bool = imagick_edge([image handle],[the radius of the pixel neighbor- hood; using 0 will cause a suitable radius to be selected for you]) 边缘锐化
  bool = imagick_emboss([image handle],[the radius of the pixel neighbor-
hood],[the standard deviation of the Gaussian, in pixels])
浮雕效果
  bool = imagick_enhance([image handle]) 图象增强
  bool = imagick_gaussianblur([image handle],[he radius of the Gaussian, in pixels, not counting the center pixel; using 0 will cause a suitable radius to be selected for you],[the standard deviation of the Gaussian, in pixels]) 高斯模糊
  bool = imagick_medianfilter([image handle],[the radius of the pixel neighbor-hood]) 平滑过滤图象
  bool = imagick_motionblur([image handle],[the radius of the Gaussian, in
pixels, not counter the center pixel],[the standard deviation of the
Gaussian, in pixels],[apply the effect along this angle])
动感模糊
  bool = imagick_reducenoise([image handle],[the radius of the pixel neighborhood]) 降噪
  bool = imagick_shade 阴影
  bool = imagick_sharpen 锐化
  bool = imagick_spread 发散
  bool = imagick_threshold 临界值
  bool = imagick_unsharpmask unsharpmask锐化
  UN KNOW USE bool = imagick_flatten  
图片列表类 bool = imagick_next  
  bool = imagick_prev  
  bool = imagick_first  
  bool = imagick_goto  
  bool = imagick_getlistsize  
  bool = imagick_getlistindex  
  bool = imagick_getimagefromlist  
  bool = imagick_pushlist  
  bool = imagick_poplist  
图片变形类 bool = imagick_chop  
  bool = imagick_crop([image handle],[x starting position of border],[y starting position of border],[width of border],[height of border]) 从图片上截取
  bool = imagick_flip ([image handle]) 图象翻转
  bool = imagick_flop 左右转换
  bool = imagick_roll  
  bool = imagick_profile  
  bool = imagick_rgbtransform 色彩变更
  bool = imagick_transformrgb 色彩变更
  bool = imagick_mosaic  
  bool = imagick_transparent([image handle],[color value]) 设置指定颜色成为透明色
图片量子化 bool = imagick_ordereddither([image handle])  
图片合成类 bool = imagick_composite 图象融合
图片属性设置 bool = imagick_set_image_comment([image handle],[the comment to set in the image]) 设置图象的一些参数
  bool = imagick_set_image_quality([image handle],[quality value]) 设置图象的质量
句柄销毁类 bool = imagick_destroyhandle([image handle]) 干掉指定的image handle
兼容的函数 imagick_read => imagick_readimage  
  imagick_free => imagick_destroyhandle  
抛弃的函数 imagick_add_resource  
  imagick_list_magickinfo  
  imagick_new  
  imagick_init  
  imagick_copy_sample  
  imagick_copy_resize  
  imagick_copy_crop  
  imagick_copy_shear  
  imagick_copy_rotate  
  imagick_copy_morph  
  imagick_dump  

Document Version 0.1 by hoowa_sun

Document Copyright By hoowa_sun. your need copyright line of pub into others.


 

LNMP集成环境

Publish: February 8, 2012 Category: PHP,MYSQL,Centos,Nginx No Comments

http://lnmp.org/

flexpaper 参数说明

Publish: February 8, 2012 Category: PHP,FlexPaper No Comments

 

Flexpaper可能用到如下参数


   SwfFile (String) 需要使用Flexpaper打开的文档
   Scale (Number) 初始化缩放比例,参数值应该是大于零的整数
   ZoomTransition (String) Flexpaper中缩放样式,它使用和Tweener一样的样式,默认参数值为easeOut.其他可选值包括: easenone, easeout, linear, easeoutquad
   ZoomTime (Number) 从一个缩放比例变为另外一个缩放比例需要花费的时间,该参数值应该为0或更大。
   ZoomInterval (Number) 缩放比例之间间隔,默认值为0.1,该值为正数。
   FitPageOnLoad (Boolean) 初始化得时候自适应页面,与使用工具栏上的适应页面按钮同样的效果。
   FitWidthOnLoad (Boolean) 初始化的时候自适应页面宽度,与工具栏上的适应宽度按钮同样的效果。
   localeChain (String) 设置地区(语言),目前支持以下语言。

en_US (English) 
fr_FR (French) 
zh_CN (Chinese, Simple) 
es_ES (Spanish) 
pt_BR (Brazilian Portugese) 
ru_RU (Russian) 
fi_FN (Finnish) 
de_DE (German) 
nl_NL (Netherlands) 
tr_TR (Turkish) 
se_SE (Swedish) 
pt_PT (Portugese) 
el_EL (Greek) 
da_DN (Danish) 
cz_CS (Czech) 
it_IT (Italian) 
pl_PL (Polish) 
pv_FN (Finnish) 
hu_HU (Hungarian)
   FullScreenAsMaxWindow (Boolean) 当设置为true的时候,单击全屏按钮会打开一个flexpaper最大化的新窗口而不是全屏,当由于flash播放器因为安全而禁止全屏,而使用flexpaper作为独立的flash播放器的时候设置为true是个优先选择。
   ProgressiveLoading (Boolean) 当设置为true的时候,展示文档时不会加载完整个文档,而是逐步加载,但是需要将文档转化为9以上的flash版本(使用pdf2swf的时候使用-T 9 标签)。
   MaxZoomSize (Number) 设置最大的缩放比例。
   MinZoomSize (Number) 最小的缩放比例。
   SearchMatchAll (Boolean) 设置为true的时候,单击搜索所有符合条件的地方高亮显示。
   InitViewMode (String) 设置启动模式如"Portrait" or "TwoPage".
   ViewModeToolsVisible (Boolean) 工具栏上是否显示样式选择框。
   ZoomToolsVisible (Boolean) 工具栏上是否显示缩放工具。
   NavToolsVisible (Boolean) 工具栏上是否显示导航工具。
   CursorToolsVisible (Boolean) 工具栏上是否显示光标工具。
  

SearchToolsVisible (Boolean)

工具栏上是否显示搜索。


 

SWFTOOLS PDF2SWF 参数详解

Publish: February 8, 2012 Category: PHP,Centos No Comments

font2swf.exe 
gif2swf.exe 
jpeg2swf.exe 
pdf2swf.exe 
png2swf.exe 
wav2swf.exe 
具体的功能就顾名思义了。 

其中把pdf转成swf的工具就是pdf2swf了。在命令行中运行pdf2swf src.pdf des.swf一般能满足需求。而命令行参数可以通过pdf2swf -f得到: 

-h , –help                      Print short help message and exit              打印帮助信息 
-V , –version                Print version info and exit                        打印版本号 
-o , –output file.swf         Direct output to file.swf. If file.swf contains ‘13568621′ (file13568630.swf), then each page指定输出的swf文件名 
-p , –pages range             Convert only pages in range with range e.g. 1-20 
or 1,4,6,9-11 or 

指定转换的页面范围,使用的页码描述方法与打印机打印文件时候的选页一样 

-P , –password password       Use password for deciphering the pdf.指定打开pdf的密码 
-v , –verbose                 Be verbose. Use more than one -v for greater effect.转换时输出详细的内容 
-z , –zlib                    Use Flash 6 (MX) zlib compression.使用Flash 6的zlib压缩机制 
-i , –ignore                  Allows pdf2swf to change the draw order of the pdf. This may make the generated允许程序修改pdf的绘制顺序,可能会导致结果与原来有差异 
-j , –jpegquality quality     Set quality of embedded jpeg pictures to quality. 0 is worst (small), 100 is best (big). (default:85)设置转换其中的jpeg图片的质量,从0到100,默认值是85。 
-s , –set param=value         Set a SWF encoder specific parameter.  See pdf2swf -s help for more information.  设置SWF转码时候的参数,具体参数可以用pdf2swf -s help获取 
-w , –samewindow              When converting pdf hyperlinks, don’t make the links open a new window.        设置转换后的swf打开原pdf中的连接时使用相同的窗口 
-t , –stop                    Insert a stop() command in each page.            在每页结尾添加一个stop()命令 
-T , –flashversion num        Set Flash Version in the SWF header to num.         设置SWF所使用的flash版本号 
-F , –fontdir directory       Add directory to the font search path.                    指定字体文件所在路径 
-b , –defaultviewer           Link a standard viewer to the swf file.             指定默认的swf导航文件,用来翻页、放大缩小等等 
-l , –defaultloader           Link a standard preloader to the swf file which will be displayed while the main swf is loading.     指定默认的swf加载文件,用来显示加载进程效果 
-B , –viewer filename         Link viewer filename to the swf file.   指定swf导航文件,作用同-b 
-L , –preloader filename      Link preloader filename to the swf file.      指定swf加载文件,作用同-l 
-q , –quiet                   Suppress normal messages.  Use -qq to suppress warnings, also.  不打印普通信息,用-qq就不打印警告信息。 
-S , –shapes                  Don’t use SWF Fonts, but store everything as shape. 不使用字体,所有都转为形状。 
-f , –fonts                   Store full fonts in SWF. (Don’t reduce to used characters). 在swf中保存全部字体。 
-G , –flatten                 Remove as many clip layers from file as possible. 在文件中尽量去除影片层,合并它们 
-I , –info                    Don’t do actual conversion, just display a list of all pages in the PDF. 不做实际转换,仅显示PDF的信息。 
-Q , –maxtime n               Abort conversion after n seconds. Only available on Unix. 如果运行时间超时则退出。 

-------------------------------------------------------------------------------- 
然后看看-s都可以设置些什么: 
PDF Parameters: 
PDF device global parameters: 
fontdir= a directory with additional fonts 指定字体目录, 与1级参数的-F相若 
font= an additional font filename 增加额外的字体文件 
pages= the range of pages to convert (example: pages=1-100,210-) 指定页面范围,与1级参数的-p相若 
zoom= the resolution (default: 72) 指定分辨率,默认为72dpi 
languagedir= Add an xpdf language directory 增加一个xpdf的语言目录,对非西欧字符有用 
multiply= Render everything at the resolution 在几倍分辨率下渲染 
poly2bitmap Convert graphics to bitmaps 把其中的图形转成点阵 
bitmap Convert everything to bitmaps 把所有内容转成点阵(包括字体) 

SWF Parameters: 

SWF layer options: 
jpegsubpixels=<pixels> resolution adjustment for jpeg images (same as jpegdpi, but in pixels) jpeg图片的分辨率 
ppmsubpixels=<pixels> resolution adjustment for  lossless images (same asppmdpi, but in pixels) 无损图片的分辨率 
subpixels=<pixels>     shortcut for setting both jpegsubpixels and ppmsubpixels 快速设置上两个参数 
drawonlyshapes           convert everything to shapes (currently broken) 所有都转成图形 
ignoredraworder         allow to perform a few optimizations for creating smaller SWFs 允许执行一些小优化 
linksopennewwindow   make links open a new browser window 链接打开新窗口 
linktarget                  target window name of new links       新链接窗口的名称 
linkcolor=<color)        color of links (format: RRGGBBAA)    链接的颜色 
linknameurl         Link buttons will be named like the URL they refer to (handy for iterating through links with actionscript)   链接名称与链接URL一致 
storeallcharacters      don’t reduce the fonts to used characters in the output file 保存所有的字符字体 
enablezlib                switch on zlib compression (also done if flashversion>=7) 使用zlib压缩 
bboxvars                 store the bounding box of the SWF file in actionscript variables 在as中保存swf的区域大小 
dots                        Take care to handle dots correctly 保存单点显示 
reordertags=0/1     (default: 1) perform some tag optimizations 执行某些tag优化 
internallinkfunction=<name> when the user clicks a internal link (to a different page) in the converted file, this actionscript function is called 内部链接函数,如果点击一个内部链接,将调用该actionscript函数 
externallinkfunction=<name> when the user clicks an external link (e.g. http://www.foo.bar/) on the converted file, this actionscript function is called 外部链接函数,如果点击一个外部链接,将调用该actionscript函数 
disable_polygon_conversion  never convert strokes to polygons (will remove capstyles and joint styles) 不要将笔画转成多边形 
caplinewidth=<width>        the minimum thichness a line needs to have so that capstyles become visible (and are converted)           线条最低转换宽度,比这个细的线条将不转换 
insertstop                  put an ActionScript “STOP” tag in every frame 在swf的每个桢中添加stop()函数 
protect                     add a “protect” tag to the file, to prevent loadingin the Flash editor 增加protect标签,禁止在flash中加载该swf 
flashversion=<version>  the SWF fileversion (6) 设置最低swf版本 
framerate=<fps>         SWF framerate  设置桢率 
minlinewidth=<width>  convert horizontal/vertical boxes smaller than thiswidth to lines (0.05)将宽度少于某值的矩形转成线条 
simpleviewer     Add next/previous buttons to the SWF 使用简单的导航 
animate           insert a showframe tag after each placeobject (animate draw order of PDF files) ??? 
jpegquality=<quality>  set compression quality of jpeg images 设置jpeg的压缩质量 
splinequality=<value>  Set the quality of spline convertion to value (0-100, default: 100). 设置样条曲线的转换质量 
disablelinks                Disable links.  禁止链接 

php生成任意位数随机提取码

Publish: February 3, 2012 Category: PHP No Comments

function make_password( $length = 8 )
{
    // 密码字符集,可任意添加你需要的字符
    $chars = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 
    'i', 'j', 'k', 'l','m', 'n', 'o', 'p', 'q', 'r', 's', 
    't', 'u', 'v', 'w', 'x', 'y','z', 'A', 'B', 'C', 'D', 
    'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L','M', 'N', 'O', 
    'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z', 
    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');

    // 在 $chars 中随机取 $length 个数组元素键名
    //$keys = array_rand($chars, $length); 

    $password = '';
    for($i = 0; $i < $length; $i++)
    {
        // 将 $length 个数组元素连接成字符串
        $password .= $chars[array_rand($chars)];
    }

    return $password;
}