I want to resize the input image to a fixed size. Then I want to entire content of the resized image file in a buffer for further use like, appending it with other buffer(data).
Currently I am doing it using the following python function,
def get_resize_img(img_file):
img = Image.open(img_file)
img = img.resize((640,960), Image.NEAREST)
img.save("tmp_out.jpg")
fp = open("tmp_out.jpg", "rb")
data = fp.read()
fp.close()
print "img sz:", len(data)
return data
Is there any better way to achieve this without writing into a dummy file (tmp_out.jpg) and reading back from it.
-Mohan
1 Answer