Skip to content

Finnish specs per Police guide, clearer head guides, background removal strength, JPEG size limits - #1

Open
whcrg wants to merge 4 commits into
RefNull:mainfrom
whcrg:fi-police-photo-rules
Open

whcrg wants to merge 4 commits into
RefNull:mainfrom
whcrg:fi-police-photo-rules

Conversation

@whcrg

@whcrg whcrg commented Oct 28, 2026

Copy link
Copy Markdown

Summary

Checked the Finnish specs against the Finnish Police photo guide (Poliisin passikuvaohje 2020) and fixed them. Also clearer head guides, a background-removal strength slider, and JPEG output for specs with an upload size limit.

Finnish specs (passport, ID card, visa; paper and online)

Before Police guide
Head height min 35 mm / 487 px, no max 32–36 mm / 445–500 px
Space above crown min 4 mm 4–6 mm / 56–84 px
Space below chin — 7–9 mm / 96–124 px
Face centre line — within 1.5 mm / 21 px of photo centre
Online photo dpi 600 (printed at 21×28 mm) 352.8 (500 px = 36 mm)

The guide covers police-issued documents (passport, ID card, permits); the visa spec got the same values.

New optional spec rules to express this: maxHeadOffset, minChinOffset, maxChinOffset, maxCenterOffset (fractions of photo height, like the existing ones). Automatic framing keeps the crown and chin inside those bands.

Head guide

  • Crown and chin bands drawn as min/max marker lines when a spec sets them.
  • Head outlines span the bands: smallest head between the inner edges, largest between the outer edges (32 and 36 mm for Finland).
  • Vertical centre line, plus the allowed drift either side when maxCenterOffset is set.
  • Every stroke is a solid black line under white dashes, so it stays visible on light and dark photos.

Background removal strength

A 0–100% slider in the retouch Background panel. Below 100% the same crop of the original photo is blended back under the cutout at 1 − removal opacity, which looks less processed. The original is scaled to the cutout's resolution before cropping (the crop area is measured on the cutout); if their shapes differ the slider is hidden. A note says authorities may still treat it as an edited photo. Strings added for all 15 locales (non-English ones not reviewed by native speakers).

Upload size limits

Specs with rules.size (e.g. Finland online, 250 KB) now save as JPEG at the highest quality (0.95 → 0.5, binary search) that fits, instead of always PNG with a warning. Transparent backgrounds go on white. The warning stays if even the lowest quality doesn't fit. Other specs are unchanged (PNG with print density).

packages/mcp/dist is rebuilt since it bundles solveCrown and the spec data; check:dist passes.

Testing

  • tsc, lint and tests pass for common (2,581 tests, including new placement, spec and size-encoding tests), web and mcp (84 tests).
  • Checked in the browser: Finnish guide bands and outlines, slider blending, Finland online save → 500×653 JPEG, 64.8 KB.

🤖 Generated with Claude Code

whcrg and others added 4 commits October 28, 2026 09:30
Check the Finnish passport, ID card and visa specs against the Finnish
Police photo guide (Poliisin passikuvaohje 2020) and fix them:

- Head height 32-36 mm (445-500 px online), not "at least 35 mm"
  (487 px), which was above the official maximum range.
- Add the guide's other bounds: 4-6 mm above the crown, 7-9 mm below
  the chin, face centre line within 1.5 mm of the photo centre.
- Online photos are 500x653 px = 36x47 mm, so use 352.8 dpi instead of
  600 (which made them print at 21x28 mm).

To express these, specs can now set maxHeadOffset, min/maxChinOffset
and maxCenterOffset. Automatic framing keeps the crown and chin inside
those bands, and the head guide draws them as min/max marker lines.

The guide also gets a vertical centre line (with the allowed drift
either side when a spec sets one), and every guide stroke is drawn as
alternating black and white dashes so it stays visible on any photo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a spec has crown or chin bands, the head outlines now span them:
the smallest head from the inner edge of the crown band to the inner
edge of the chin band, the largest between the outer edges. For the
Finnish specs that is exactly 32 and 36 mm.

Add a "Background removal" slider (0-100%) to the retouch Background
panel. Below 100% the original photo is blended back in under the
cutout, so some of the original background shows through and the photo
looks less processed. The cropper hands retouching the same crop of the
original alongside the cutout. A note says authorities may still treat
it as an edited photo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crop area is measured on the cutout, which background removal may
return at a different resolution from the original. Scale the original
to the cutout's size before cropping it for the blend, and skip the
blend (hiding the slider) when the two don't have the same shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Specs with an upload limit (rules.size, e.g. Finland online: 250 KB)
were always saved as PNG and only warned when too large. Save them as
JPEG instead, at the highest quality (0.95 down to 0.5, by binary
search) that fits the limit, on white where the background is
transparent. Online submissions such as the Finnish Police's expect
JPEG anyway. The warning remains for the rare photo that still does not
fit at the lowest quality. Other specs stay PNG with print density.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant