Added exiftool and function to remove GPS data from EXIF

This commit is contained in:
2025-05-14 15:48:38 +02:00
parent 15ac64583e
commit 29f0975ecd
2 changed files with 14 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
FROM alpine:3.21 FROM alpine:3.21
RUN apk add curl python3 RUN apk add curl python3 exiftool
RUN adduser -D kakigoori RUN adduser -D kakigoori
USER kakigoori USER kakigoori

View File

@@ -1,3 +1,5 @@
import subprocess
import boto3 import boto3
from botocore.config import Config from botocore.config import Config
from django.conf import settings from django.conf import settings
@@ -15,3 +17,14 @@ def get_b2_resource():
bucket = b2.Bucket(settings.S3_BUCKET) bucket = b2.Bucket(settings.S3_BUCKET)
return 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)