2 Star 6 Fork 2

zhangsongfu / imagemagick_nginx_module

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_image.py 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
zhangsongfu 提交于 2012-07-31 14:22 . later modify readme and test_image.py
import httplib
def test_post():
f = open('big.jpg', 'r')
data = f.read()
f.close()
conn = httplib.HTTPConnection("192.168.1.35:81")
headers = {
"Content-Length": len(data),
"X-ImageMagick-Convert": "-strip -quality 80 -resize 500x500>"
}
conn.request("POST", "/magickd/", data, headers)
rsp = conn.getresponse()
print 'Status %s %s' % (rsp.status, rsp.reason)
for h in rsp.getheaders():
print '%s: %s' % (h[0], h[1])
if rsp.status == 200:
data = rsp.read()
f = open('converted_post1.jpg', 'wb')
f.write(data)
f.close()
def test_get():
conn = httplib.HTTPConnection("192.168.1.35:81")
# X-ImageMagick-Convert=/testdata/testimage.jpg -strip -resize 500x500>
headers = {
"X-ImageMagick-Convert": "/fw554.jpg -strip -resize 500x500>"
}
conn.request("GET", "/magickd/", None, headers)
rsp = conn.getresponse()
print 'Status %s %s' % (rsp.status, rsp.reason)
for h in rsp.getheaders():
print '%s: %s' % (h[0], h[1])
if rsp.status == 200:
data = rsp.read()
f = open('converted_get.jpg', 'wb')
f.write(data)
f.close()
if __name__ == '__main__':
test_get()
#test_post()
C
1
https://gitee.com/dandingboshi/imagemagick_nginx_module.git
git@gitee.com:dandingboshi/imagemagick_nginx_module.git
dandingboshi
imagemagick_nginx_module
imagemagick_nginx_module
master

搜索帮助