diff --git a/Dockerfile b/Dockerfile index 8d43a06..583db65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3.21 -RUN apk add curl python3 +RUN apk add curl python3 exiftool RUN adduser -D kakigoori USER kakigoori diff --git a/images/utils.py b/images/utils.py index 804a4cc..aee658d 100644 --- a/images/utils.py +++ b/images/utils.py @@ -1,3 +1,5 @@ +import subprocess + import boto3 from botocore.config import Config from django.conf import settings @@ -15,3 +17,14 @@ def get_b2_resource(): bucket = b2.Bucket(settings.S3_BUCKET) return bucket + + +def remove_exif_gps_data(image_data: bytes) -> bytes: + result = subprocess.run( + ["exiftool", "-gps:all=", "-"], input=image_data, capture_output=True + ) + + if not result.check_returncode(): + return image_data + else: + raise Exception(result.stderr)