手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表分类:PHP

服务器正式启用ImagIck组件

Imagick的DLL在windows上本来无法装上,前面一篇博客里介绍说团队好友hihiyou帮忙找了一个DLL,可以用在PHP 5.2.X上面的,今天一大早COPY到服务器上,并扩展出来。。

看图说话,OH YEAH。可惜。。。sablog不支持Imagick,它还是用GD的,不知道新版本会不会采用。

好象小图看不太清楚。还是点击一下看大图吧。。。

大小: 31.27 K
尺寸: 398 x 376
浏览: 2606 次
点击打开新窗口浏览全图

Tags: imagick, 安装

关于Imagick的使用

ImagIck这个控件应该算是最近两年来,各个WEB程序员都比较推荐的一个编辑图片的软件。
其实这也是一个分支吧?如果我没有记错,都是从XXX(忘了是哪个了)分出来的,一个是MagickWand,另一个就是这个Imagick了,只是MagicWand好象比较难以控制,并不如这个Imagick方便,再加上Imagick的类及使用方法也集成在PHP手册里了。

本来我是安装了ImageMagick-6.2.5-4-Q16-windows-dll.exe的,然而,愿望总是美好的,结果在Apache下运行的时候,总是提示挂接不上某个动态链接库,装回5.5.7后一切正常,但却无法使用PHP手册里所提供的函数。

本来都想放弃了,可是同事在单位里的Linux上装上了这个软件,但由于我们的PHP版本太低,在大多数的情况下都是直接使用命令行进行操作的。

为了适应将来的PHP版本升级,所以不得不学习这个软件,在我以前的贴子里,也贴过了Imagick官网和一些例子的实现网站。
今后我也会重新拾起代码,尽量、争取把官网的例子也逐步一一实现,或者大部分常用的实现一下。

感谢团队好友hihiyou(http://www.hihiyou.com)为我找了一个可以在windows下使用的Imagick的DLL,可以让我开始学习它。

先来个例子,黑黑。。。

PHP代码
  1. <?php  
  2. header('Content-type: image/gif');  
  3.   
  4. $image = new Imagick('google_logo.gif');  
  5. $image->adaptiveResizeImage(400,NULL);  
  6.   
  7. echo $image;  
  8. ?>  

原图:

 

大小: 8.36 K
尺寸: 276 x 110
浏览: 2335 次
点击打开新窗口浏览全图

重生成:

大小: 18.96 K
尺寸: 400 x 159
浏览: 2311 次
点击打开新窗口浏览全图

Tags: imagick, php, extension, dll

闲着无聊,用WPS生成文档

不好意思,该操作只能在windows服务器上才能执行,是因为,只有windows服务器才支持COM功能,而且,必须安装wps(这点应该不难,因为WPS是免费软件)
免费软件这点太重要了,如果你要生成WORD,你不可能安装一个OFFICE吧,office太贵了。

PHP代码
  1. <?php  
  2. $wps = new COM("WPS.Application");  
  3. $wps->Visible = false;  
  4. $doc = $wps->Documents->Add();  
  5. $doc->Range->Text = 'WPS FOR PHP test';  
  6. $doc->Paragraphs[1]->Alignment = 1;  
  7. $doc->Shapes->AddPicture("http://img.kingsoft.com/publish/kingsoft/images/gb/sy/logo.gif", 100, 50, 148, 60);  
  8. $doc->SaveAs('c:\\temp\\test1.wps');  
  9. $doc->Close();  
  10. $wps->Quit();  
  11. unset( $doc , $wps );  
  12. ?>  

代码很简单,只是添加了一个文字和一个图片而己。但是,证明了是可以使用这个功能。
大家别忘了,WPS的附加功能可是很多的,比如把文件转为PDF等格式。也就是说, 如果是在windows服务器上,我们要生成PDF,可以不使用那些什么fpdf类库,而是使用WPS先生成一个WORD格式的文档,然后直接exportPdf就可以了。要知道OFFICE默认并不支持这种功能。黑黑

这也是一种思路嘛,思路决定出路,转换一种思路,可能就是海阔天空。

这里是WPS的开发者网站:http://wps.kingsoft.com/apply/engineer.shtml,从这里可以下载API:http://wps.kingsoft.com/download/WPSAPI.zip

Tags: php, wps, com, wps application

为windows的WEB服务器添加高性能的FTP组件

在windows服务器里面,如果我们要用FTP函数,速度应该是很慢的,而且效率不高,如果有大量文件需要上传,用自带的FTP函数,恐怕是要死人的吧。
windows服务器,windows哦,可以装N多软件的windows哦。虽然不建议在服务器上装上很多软件,但是也可以装一些FTP软件的嘛。这里以cuteftp举例。
cuteftp安装完毕后,会在软件目录里有一个Scripts目录,现在的版本不象很久以前的了,如今的版里只有一个Sample.vbs,记得几年前的cuteftp里面会有各种各样的vbs文件的。
闲话不多说,打开vbs文件,内容为:

ASP/Visual Basic代码
  1. 'This default template script is in VBScript. You can write scripts in your language of choice and save them with the proper extension, or use your an editor specific to that language.  
  2. 'See the TESDK help file for more details on how the scripting feature works and for information on each supported method and property.  
  3. 'You must have Windows Scripting Host installed for the COM enabled engine to work. Run the Transfer Engine once to register it (as a COM object) on the target system.  
  4. 'If you're having problems with running scripts while not logged in, or when trying to run them using MS scheduler, refer to our online knowledgebase for help (http://www.globalscape.com/support)  
  5. 'Look into c:\temp folder to observe local activity (for testing purposes) or right click on the Transfer Engine icon in the systray and select "show current transfers"  
  6. 'This sample script performs an anonymous login to ftp://ftp.globalscape.net  
  7.    'First declare a variable called Mysite. This will hold the reference to the TE COM object.  
  8.    Dim MySite  
  9.    'Create a connection object and assign it to the variable  
  10.    Set MySite = CreateObject("CuteFTPPro.TEConnection")  
  11.    ' Now set each property for the site connection   
  12.    ' You can omit this section to use the default values, but you should at least specify the Host  
  13.    'The default Protocol is FTP, however SFTP (SSH2), FTPS (SSL), HTTP, and HTTPS can also be used)  
  14.    MySite.Protocol = "FTP"  
  15.    MySite.Host = "ftp.globalscape.com"  
  16.    'following lines are optional since the default is anonymous if no login and password are defined  
  17.    MySite.Login = "anonymous"  
  18.    MySite.Password = "user@user.com"  
  19.    'if necessary, use the UseProxy method and ProxyInfo or SocksInfo properties to connect through a proxy server  
  20.    MySite.UseProxy = "BOTH"  
  21.    'now connect to the site (also called called implicitly when most remote methods are called)  
  22.    MySite.Connect  
  23.    'perform some logic to verify that the connection was made successfully  
  24.    If (Not Cbool(MySite.IsConnected)) Then    
  25.       MsgBox "Could not connect to: " & MySite.Host & "!"  
  26.       Quit(1)  
  27.    End If  
  28.    'The script will now check to see if the local folder c:\temp exists and will create it if necessary  
  29.    If (Not (MySite.LocalExists("c:\temp"))) Then  
  30.       MySite.CreateLocalFolder "c:\temp"  
  31.    End If  
  32.    'Change TE's local working folder to to c:\temp  
  33.    MySite.LocalFolder = "c:\temp"  
  34.    'Check for existence of remote folder "/pub/cuteftp"  
  35.    b = MySite.RemoteExists("/pub/cuteftp/")  
  36.    If (Not CBool(b)) Then  
  37.       'Verify existence of remote folder  
  38.       MsgBox "Remote folder not found!. Please make sure that the Pub folder exists on the remote site"  
  39.       Quit(1)  
  40.    End If  
  41.    'Now download the index file to the local destination folder  
  42.    MySite.Download "/pub/cuteftp/index.txt"  
  43.    'Complete.  Show the status of this transfer.  
  44.    MsgBox "Task done, final status is '" + MySite.Status + "'"  
  45.   MySite.Disconnect  
  46.   MySite.Close  
  47. 'End of sample script. You can save you script and then run it by either selecting it from the Tools > Run Script menu or by double clicking on the script file in Windows  

看到这样的文件,你应该知道如何调用一些FTP软件自带的方法了吧?现在,我们用PHP模拟一遍。。。。。
请看详细内容

» 阅读全文

Tags: ftp, com, windows, cuteftp, vbs

佛家思想与PHP开发

今天听了点课,感悟还是有点的。软件开发会时不时的遇到点瓶颈,这其实与佛家思想还是有点关系的,当然,也许是我硬套上的吧。

佛家参惮有一种说法:看山是山,看水是水;看山不是山,看水不是水;看山还是山,看水还是水。这里说的是佛家修行的三个层次,也叫三重境界,即初期看山是山,中期有悟时,山就不再是简单的山了,最后彻悟,返朴归真,山还是山,但已经不是原来的那个山了,升华了,空灵了。把这用在游记上也是很合适的。走马观花,照象机式的记录,见山是山,见水是水,见什么写什么,流水帐,千篇一律,大同小异,这是初级阶段。再上一个层次,进到文学的创作,那就得看山不是山,看水不是水。那是什么?是山水背后的东西,附在山水之上的东西,山不再是单纯岩石泥土加草木的立体,水也不是简单的流动的液体了。

软件开发也差不多,刚开始学程序的时候,看山是山,因为这时候思想还没有成形,对于程序的理解都是停在表面上,没有什么特别的概念。随着编程时间的增长,和能力的进步,这时候看待程序、架构都比较的深层次了,于是就升级成为看山不是山,看水不是水的境界。这道坎其实很难跨越,等到真正跨越这一层,然后所以的编程语言、架构在眼里又变成那样的浅显,于是又回到了最初的看山是山看水是水的境界。

随便说说而己。不必生搬硬套

Tags: 佛家思想, 感悟, 开发, php