Refactors Services and Initial Test Implementation
This commit is contained in:
1
storage_service/utils/file/validators/__init__.py
Normal file
1
storage_service/utils/file/validators/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .image_handler import image_validator
|
||||
20
storage_service/utils/file/validators/image_handler.py
Normal file
20
storage_service/utils/file/validators/image_handler.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from PIL import Image
|
||||
|
||||
import io
|
||||
|
||||
|
||||
def image_validator(file_bytes: io.BytesIO) -> io.BytesIO:
|
||||
img = Image.open(file_bytes)
|
||||
|
||||
img.thumbnail((180, 180))
|
||||
|
||||
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