Menu

1 / 2

Blur Faces in Photos Automatically with Python (GDPR)

DEV Community: computervision·AI Engine·about 6 hours ago
#k8zRNFsk
Reading 0:00
15s threshold

Street shots for a city guide, user uploads, a training dataset, a CCTV clip someone asked for under GDPR: all of them are full of faces of people who never agreed to be published. Here is how to blur them automatically in Python: one API call finds every face, Pillow pixelates them, and the saved file drops the GPS metadata too.

All numbers below come from live calls on six crowded street photos and one party photo.

Want to run it on your own photos? Get a key for the Face Analyzer API .

Step 1: detect every face

import os import requests from concurrent.futures import ThreadPoolExecutor from PIL import Image , ImageFilter , ImageOps

BASE = " https://faceanalyzer-ai.p.rapidapi.com " HEADERS = { " x-rapidapi-host " : " faceanalyzer-ai.p.rapidapi.com " , " x-rapidapi-key " : " YOUR_API_KEY " , }

def detect_faces ( path ): """ Return the bounding box of every face in the image (0 to 1 coordinates). """ with open ( path , " rb " ) as f : r = requests .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.