mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2025-01-18 17:15:13 +01:00
Strip EXIF data to secure photo location
This commit is contained in:
parent
730fcf5883
commit
01bb0b1229
@ -1,6 +1,7 @@
|
||||
import os
|
||||
import logging
|
||||
import shutil
|
||||
from PIL import Image
|
||||
from app.classes.models.server_permissions import EnumPermissionsServer
|
||||
from app.classes.shared.helpers import Helpers
|
||||
from app.classes.web.base_api_handler import BaseApiHandler
|
||||
@ -281,6 +282,21 @@ class ApiFilesUploadHandler(BaseApiHandler):
|
||||
with open(chunk_file, "rb") as infile:
|
||||
outfile.write(infile.read())
|
||||
os.remove(chunk_file)
|
||||
if upload_type == "background":
|
||||
# Strip EXIF data
|
||||
image_path = os.path.join(file_path)
|
||||
logger.debug("Stripping exif data from image")
|
||||
image = Image.open(image_path)
|
||||
|
||||
# Get current raw pixel data from image
|
||||
image_data = list(image.getdata())
|
||||
# Create new image
|
||||
image_no_exif = Image.new(image.mode, image.size)
|
||||
# Restore pixel data
|
||||
image_no_exif.putdata(image_data)
|
||||
|
||||
image_no_exif.save(image_path)
|
||||
|
||||
logger.info(
|
||||
f"File upload completed. Filename: {self.filename}"
|
||||
f" Path: {file_path} Type: {u_type}"
|
||||
|
@ -20,3 +20,4 @@ tzlocal==5.1
|
||||
jsonschema==4.19.1
|
||||
orjson==3.9.15
|
||||
prometheus-client==0.17.1
|
||||
pillow==10.4.0
|
Loading…
x
Reference in New Issue
Block a user