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, "BMP", 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")
54 im.save("lena2.jpg",quality=quality)
56 for i in range(nb_times):
58 im.save(buf, "JPEG", quality=quality)
60 elapsed_time += time.time() - t
62 print("time noscale jpg",elapsed_time/nb_times)
67 im2=im.resize((256, 256))
68 im2.save("lena3.jpg",quality=quality)
70 for i in range(nb_times):
71 im2=im.resize((256, 256))
73 im2.save(buf, "JPEG", quality=quality)
75 elapsed_time += time.time() - t
76 print("time resize + pil",elapsed_time/nb_times)
84 sbuf = buffer.Buffer(s)
90 for i in range(nb_times):
92 sbuf.put_utf8(file_name)
94 file_size = os.path.getsize(file_name)
95 sbuf.put_utf8(str(file_size))
97 with open(file_name, 'rb') as f:
98 sbuf.put_bytes(f.read())
100 elapsed_time += time.time() - t
101 print("send lena.bmp ",elapsed_time/nb_times)
105 file_name="lena2.jpg"
106 for i in range(nb_times):
108 sbuf.put_utf8(file_name)
110 file_size = os.path.getsize(file_name)
111 sbuf.put_utf8(str(file_size))
113 with open(file_name, 'rb') as f:
114 sbuf.put_bytes(f.read())
116 elapsed_time += time.time() - t
117 print("send noscale lena2.jpg ",elapsed_time/nb_times)
121 file_name="lena3.jpg"
122 for i in range(nb_times):
124 sbuf.put_utf8(file_name)
126 file_size = os.path.getsize(file_name)
127 sbuf.put_utf8(str(file_size))
129 with open(file_name, 'rb') as f:
130 sbuf.put_bytes(f.read())
132 elapsed_time += time.time() - t
133 print("send scale lena3.jpg ",elapsed_time/nb_times)