惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
GbyAI
GbyAI
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
腾讯CDC
博客园 - Franky
Engineering at Meta
Engineering at Meta
C
Check Point Blog
T
The Blog of Author Tim Ferriss
有赞技术团队
有赞技术团队
Microsoft Azure Blog
Microsoft Azure Blog
MyScale Blog
MyScale Blog
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
Last Week in AI
Last Week in AI
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How Face Blur Patches Stay Aligned During Export
byeval · 2026-04-24 · via DEV Community

Blurring a face is easy if you only care about a static demo.

It gets more interesting when the user can redetect faces, expand padding, move patches, resize them, disable individual faces, change blur strength, and then export the final image without everything drifting out of alignment.

The architecture that held up best for us was patch-based.

The full companion guide is here:

https://happyimg.com/guides/how-face-blur-patches-stay-aligned-during-export

First build one blurred source image

Instead of blurring each patch independently, the editor creates a blurred version of the entire source image first:

ctx.filter = `blur(${blurStrength}px)`;
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
ctx.filter = "none";

Enter fullscreen mode Exit fullscreen mode

That gives the editor one reusable blur source for every detected face.

The advantage is practical:

  • blur strength changes rebuild one source image
  • existing patches can keep their geometry
  • face interactions stay fast

Every face is a cropped image patch

Each detected face becomes a FabricImage patch that points into the blurred source image:

const patch = new FabricImage(this.blurredSourceElement!, {
  left: region.left + region.width / 2,
  top: region.top + region.height / 2,
  width: region.width,
  height: region.height,
  cropX: region.left,
  cropY: region.top,
});

Enter fullscreen mode Exit fullscreen mode

That is the key design choice.

The editor is not blurring arbitrary rectangles on demand. It is showing cropped windows into a precomputed blurred image.

Geometry and crop source have to move together

If the user drags or resizes a blur patch, the patch cannot only change its visible rectangle. The crop window inside the blurred source has to stay aligned too.

That is why the implementation normalizes the patch back into real geometry and updates cropX and cropY alongside position and size:

patch.set({
  left: geometry.left + geometry.width / 2,
  top: geometry.top + geometry.height / 2,
  width: geometry.width,
  height: geometry.height,
  cropX: geometry.left,
  cropY: geometry.top,
  scaleX: 1,
  scaleY: 1,
});

Enter fullscreen mode Exit fullscreen mode

That reset is important. It turns temporary drag/scale transforms back into stable source-image coordinates.

Padding matters before editing starts

Face detections are usually too tight on their own, so the code expands each detection by a configurable percentage before converting it into a patch.

That gives users a better starting point and reduces the number of patches that need manual resizing just to cover the edges of a face properly.

It is a small step, but it makes the blur tool feel much less fragile.

Export should replay the current patch set

When the user exports, the editor builds a fresh StaticCanvas at original size, adds the untouched base image, then re-adds each visible blur patch with its current geometry and crop source.

That means the saved file reflects:

  • current blur strength
  • current patch positions
  • current patch sizes
  • current enabled or disabled state

Nothing depends on the on-screen viewport.

Why patch-based blur works

This model stays understandable under real editing pressure:

  • one blur source
  • many editable crop windows
  • normalized geometry after interaction
  • export rebuilt from source pixels

That is what keeps blur regions aligned even after several rounds of detection, adjustment, and export.

More implementation details:

https://happyimg.com/guides/how-face-blur-patches-stay-aligned-during-export