10 HOST = "192.168.0.106"
13 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
14 s.connect((HOST, PORT))
18 quality=int(sys.argv[1])
19 print("quality ",quality)
24 im=Image.open("lena.jpg")
25 im.save("lena.bmp",quality=quality)
28 for i in range(nb_times):
30 im.save(buf, "JPEG", quality=quality)
32 elapsed_time += time.time() - t
34 print("time in memory bmp",elapsed_time/nb_times)
38 im=Image.open("lena.jpg")
42 for i in range(nb_times):
43 im.save("lena.bmp",quality=quality)
45 elapsed_time += time.time() - t
47 print("time bmp",elapsed_time/nb_times)
52 im=Image.open("lena.jpg")
55 for i in range(nb_times):
57 im.save("lena2.jpg",quality=quality)
58 elapsed_time += time.time() - t
60 print("time noscale jpg",elapsed_time/nb_times)
66 for i in range(nb_times):
67 im2=im.resize((256, 256))
68 im2.save("lena3.jpg",quality=quality)
69 elapsed_time += time.time() - t
70 print("time resize + pil",elapsed_time/nb_times)
78 sbuf = buffer.Buffer(s)
84 for i in range(nb_times):
86 sbuf.put_utf8(file_name)
88 file_size = os.path.getsize(file_name)
89 sbuf.put_utf8(str(file_size))
91 with open(file_name, 'rb') as f:
92 sbuf.put_bytes(f.read())
94 elapsed_time += time.time() - t
95 print("send lena.bmp ",elapsed_time/nb_times)
100 for i in range(nb_times):
102 sbuf.put_utf8(file_name)
104 file_size = os.path.getsize(file_name)
105 sbuf.put_utf8(str(file_size))
107 with open(file_name, 'rb') as f:
108 sbuf.put_bytes(f.read())
110 elapsed_time += time.time() - t
111 print("send noscale lena2.jpg ",elapsed_time/nb_times)
115 file_name="lena3.jpg"
116 for i in range(nb_times):
118 sbuf.put_utf8(file_name)
120 file_size = os.path.getsize(file_name)
121 sbuf.put_utf8(str(file_size))
123 with open(file_name, 'rb') as f:
124 sbuf.put_bytes(f.read())
126 elapsed_time += time.time() - t
127 print("send scale lena3.jpg ",elapsed_time/nb_times)