Convert PIL Image to byte array?

Thanks everyone for your help.

Finally got it resolved!!

import io

img = Image.open(fh, mode="r")
roi_img = img.crop(box)

img_byte_arr = io.BytesIO()
roi_img.save(img_byte_arr, format="PNG")
img_byte_arr = img_byte_arr.getvalue()

With this i don’t have to save the cropped image in my hard disc and I’m able to retrieve the byte array from a PIL cropped image.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)