◉CLAUDE LABJP
●CC 2.1.332 — No new Claude Code release over the weekend. 2.1.332 (11/25) is still current●ANALYTICS — A fix to search counts in the Enterprise Analytics API may raise numbers from 11/17 onward●SONNET 4.5 — Today, 11/30, is Sonnet 4.5's last day on the Claude API. Move to claude-sonnet-5-5●USAGE — Some users report weekly usage jumping right after upgrading to a higher plan●NEW — New: Does what a Project remembers carry over into your everyday chats?●BILLING — More readers are looking for what to check when a payment won't go through●CC 2.1.332 — No new Claude Code release over the weekend. 2.1.332 (11/25) is still current●ANALYTICS — A fix to search counts in the Enterprise Analytics API may raise numbers from 11/17 onward●SONNET 4.5 — Today, 11/30, is Sonnet 4.5's last day on the Claude API. Move to claude-sonnet-5-5●USAGE — Some users report weekly usage jumping right after upgrading to a higher plan●NEW — New: Does what a Project remembers carry over into your everyday chats?●BILLING — More readers are looking for what to check when a payment won't go through
Articles/API & SDK
⬡ API & SDK/2026-07-11Advanced

Is This New Wallpaper Too Close to One We Already Ship? Near-Duplicate Detection with a Perceptual-Hash Pre-Filter and Claude Vision

A two-stage pipeline that catches the near-duplicates a SHA256 hash misses — recolored, lightly cropped, re-encoded — by pre-filtering with a perceptual hash and adjudicating only the close pairs with Claude Vision. With measured precision calibration and cost design from running a wallpaper catalog solo.

Claude Visionimage processingduplicate detectionperceptual hashcost design4

✦ Premium Article

I was about to add sixty freshly finished wallpapers to the catalog one morning when I stopped scrolling. That blue gradient — I feel like I've shipped something close to it before.

Memory is not reliable. Somewhere in a catalog that had grown to a few thousand images, was there really a near-match, or was I imagining it? For a while I had no way to check, and I published on a quiet "probably fine."

Shipping the same wallpaper twice with only a color change reads as recycling. It costs you a little in the store's impression, and a little in daily trust. This article is about catching the near-duplicates an exact hash never sees — using a perceptual hash and Claude Vision in two stages — with the numbers from running a wallpaper catalog as a solo indie developer.

The morning an exact hash let one slip through

My first move was to compare the raw bytes of each file with SHA256. That is airtight for duplicate files: identical bytes produce identical hashes. I once built a ledger around exactly this idea to clean up duplicates on the Files API (I wrote it up in Deduplicating with content hashes on the Files API).

In the wallpaper workflow, though, it was almost useless. The reason is simple: most of what I perceive as "similar" is, byte for byte, a different file.

OperationAppearanceSHA256
Warm the color balance slightlyNearly identicalChanges completely
Trim a few percent off the edgesNearly identicalChanges completely
Re-encode on export (quality 90 to 85)IdenticalChanges completely
Downscale by 10 percentIdenticalChanges completely

An exact hash returns an unrelated value if even one pixel differs. So the case that troubled me most — looks the same, but slightly different — was precisely the one it could never catch, by design.

What I needed was a tool that measures visual closeness, not byte equality.

Why pair a perceptual hash with Vision

The classic tool for quantifying visual closeness is the perceptual hash. You shrink the image drastically, convert it to grayscale, keep only the light-dark relationships between neighboring pixels, and fold that into 64 bits. Because color tweaks and light compression preserve the light-dark skeleton, similar images produce similar hashes.

A perceptual hash alone was not precise enough, though. Loosen the threshold and you miss fewer duplicates but also pick up unrelated designs that happen to share a composition. Tighten it and you miss the recolored near-duplicates. That band — where loosening and tightening both fail — is exactly the region a human resolves at a glance but a machine struggles with.

So I split the roles. The perceptual hash stays a cheap, fast, high-volume pre-filter for narrowing candidates, and only the final "is this essentially the same?" call goes to Claude Vision. Vision is expensive, but after the narrowing it runs very few times. Earn recall with the cheap filter; recover precision with the expensive judgment. That division of labor is the heart of the design.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Catch the recolored and lightly cropped near-duplicates that an exact SHA256 match lets slip through, using a perceptual hash and Vision in two stages
✦Cost design that avoids the all-pairs comparison (a perceptual hash trims candidate pairs to about 0.03 percent before Vision) with real precision calibration
✦An abstain route that sends the gray zone to a human queue, plus a design that avoids flagging legitimate series variations as duplicates
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ API & SDK2026-11-30
The unit price drops 20%, yet the bill may rise: estimating the Opus 4.5 to 5.5 switch before January 22
claude-opus-4-5-20251101 retires on January 22, 2027, and the official replacement is claude-opus-5-5. Prices fall by a fifth, but the tokenizer changes and thinking can no longer be turned off. You will be able to count the cost per 1,000 of your own requests and pick a replacement and an effort level.
⬡ API & SDK2026-11-25
Five Days Before Sonnet 4.5 Retires: Compare the Three Things That Change Without an Error While the Old Model Still Answers
claude-sonnet-4-5 retires on November 30. Switch the ID to claude-sonnet-5-5 and nothing returns a 400, yet thinking now runs by default, max_tokens covers more than the answer, and stop_reason shifts. Here is a small script to run the same requests on both models before the old one stops answering, and how to read the differences.
⬡ API & SDK2026-11-23
How Many Input Tokens Does One More Tool Add? Separate the Fixed Overhead From Each Tool's Weight With count_tokens
Passing tools adds a fixed, model-specific block of tokens on top of the definitions themselves. Here is a leave-one-out script for count_tokens, and how to read the shift when moving from Sonnet 4.5 to 5.5: the fixed part shrinks while the definitions grow.