+nb_times=100
+
+quality=int(sys.argv[1])
+print("quality ",quality)
+
+
+
+
+im=Image.open("lena.jpg")
+im.save("lena.bmp",quality=quality)
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+ buf = BytesIO()
+ im.save(buf, "JPEG", quality=quality)
+
+elapsed_time += time.time() - t
+
+print("time in memory bmp",elapsed_time/nb_times)
+
+
+
+im=Image.open("lena.jpg")
+
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+ im.save("lena.bmp",quality=quality)
+
+elapsed_time += time.time() - t
+
+print("time bmp",elapsed_time/nb_times)
+
+
+
+
+im=Image.open("lena.jpg")
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+
+ im.save("lena2.jpg",quality=quality)
+elapsed_time += time.time() - t
+
+print("time noscale jpg",elapsed_time/nb_times)
+
+
+
+elapsed_time=0
+t = time.time()
+for i in range(nb_times):
+ im2=im.resize((256, 256))
+ im2.save("lena3.jpg",quality=quality)
+elapsed_time += time.time() - t
+print("time resize + pil",elapsed_time/nb_times)
+
+
+
+
+
+