Refactors Project for More Declarative Package Name
This commit is contained in:
20
storage_service/utils/file_handler/handlers/image_handler.py
Normal file
20
storage_service/utils/file_handler/handlers/image_handler.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from PIL import Image
|
||||
|
||||
import io
|
||||
|
||||
|
||||
def image_handler(file_bytes: io.BytesIO) -> io.BytesIO:
|
||||
img = Image.open(file_bytes)
|
||||
|
||||
img.thumbnail((320, 320))
|
||||
|
||||
data = list(img.getdata())
|
||||
image_without_exif = Image.new(img.mode, img.size)
|
||||
image_without_exif.putdata(data)
|
||||
|
||||
new_byte_img = io.BytesIO()
|
||||
img.save(new_byte_img, format="PNG")
|
||||
|
||||
new_byte_img.seek(0)
|
||||
|
||||
return new_byte_img
|
||||
Reference in New Issue
Block a user