杜郎俊赏 - dujun.io

建站之图片大小调整

借助 imagemagick 扩展调整图片大小。 $maxSize = 2097152; //图片限制 2M $maxWidth = 1024; $maxHeight = 768; try { do { $imagick = new Imagick($imagePath); if ($maxSize >= $imagick->getImageLength()) { break; } if ($maxWidth < $imagick->getImageWidth()) {...

2017-05-18

建站之图片旋转

手机拍摄的照片存在旋转的问题,借助 imagemagick 扩展解决。 安装扩展: sudo apt-get install imagemagick sudo apt-get install php-imagick 旋转图片: try { $imagick = new Imagick($imagePath); if ($orientation = $imagick->getImageOrientation()) { switch ($orientation) { case 8: //逆时针90°...

2017-05-18

建站之 gravatar 缓存

为解决 gravatar 头像访问慢和被墙的问题,可以做本地图片备份。 $url = 'https://secure.gravatar.com/avatar/' . md5($mail) . '?s=36&r=G&d=404'; $header = get_headers($url); if (empty($header) || false === strpos($header[0], '200')) { //此邮箱不存在 gravatar 头像 } else { //抓取头像图片 $image = file_get_contents($url); }

2017-05-18

PyS60通过WAP代理上网

以下为示例代码: import httplib, urllib params = urllib.urlencode({'username':usr, 'password':pwd}) headers = {"Content-type":"application/x-www-form-urlencoded","X-Online-Host":HOST} conn = httplib.HTTPConnection("10.0.0.172:80") #中国移动WAP代理地址 conn.request("POST", PAGE, params, headers) response = conn...

2008-09-04

PyS60发中文短信的方法

在论坛看到消息,PyS60更新到1.4.3了,迅猛跟进,下载安装。仔细看了文档,发现messaging模块有更新,也因此终于知道发送中文短信时出现乱码问题的解决办法。以下作分享: 参考示例代码: # -*- coding: utf-8 -*- import messaging messaging.sms_send("137****3024", "测试中文短信".decode('utf-8'), "UCS2")

2008-05-02

Python对话框试炼:短信轰炸机

在论坛看到消息,PyS60更新到1.4.3了,迅猛跟进,下载安装。仔细看了文档,发现messaging模块有更新,也因此终于知道发送中文短信时出现乱码问题的解决办法。以下作分享: 参考示例代码: # -*- coding: utf-8 -*- import messaging messaging.sms_send("137****3024", "测试中文短信".decode('utf-8'), "UCS2")

2007-09-16

大蟒蛇初炼手记 [附源码]

在论坛看到消息,PyS60更新到1.4.3了,迅猛跟进,下载安装。仔细看了文档,发现messaging模块有更新,也因此终于知道发送中文短信时出现乱码问题的解决办法。以下作分享: 参考示例代码: # -*- coding: utf-8 -*- import messaging messaging.sms_send("137****3024", "测试中文短信".decode('utf-8'), "UCS2")

2007-08-29

分页: 1 2 3