-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_image.py
More file actions
53 lines (39 loc) · 1.1 KB
/
test_image.py
File metadata and controls
53 lines (39 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()