Photo Spec Check

Checks an exam, passport or visa photo against the portal's rules before upload and fixes size, crop and file weight in the browser.

StopsHelps prevent an exam photo being rejected after upload

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/photo-spec-check.json

The files land in your project. They're yours to edit.

Usage

photo-spec-check-usage.tsx
import { PhotoSpecCheck, type FaceBox } from "@/components/ui/photo-spec-check"

<PhotoSpecCheck key={preset} spec={preset} value={file} onValueChange={setFile} face={face} />

What it catches

  • File type that doesn't match its name
  • File size outside the KB window, and over-compression
  • Pixel size, aspect ratio or print size out of spec
  • Face too small or off-centre, when you pass a face box
  • Background that isn't white, or a black-and-white photo

Props

PhotoSpecCheck props
PropTypeDefault
spec* (required)

A preset key from `PHOTO_SPECS` ("upsc", "ssc", "nta", "neet", "us-visa") or your own spec.

string | PhotoSpec—
value

Controlled file.

File | null—
defaultValue

Initial file when uncontrolled.

File | nullnull
onValueChange

Called with the chosen file, or the fixed copy after a one-tap fix.

(file: File | null) => void—
face

The face (or head) box in the file's pixels, or a detector that returns one. Enables the face checks and a face-aware crop.

FaceBox | null | ((file: File) => FaceBox | null | Promise<FaceBox | null>)—
onIssuesChange

Called whenever the open issues change, to gate the upload.

(issues: PhotoIssue[]) => void—
messages

Any visible string; `issues` may be partial.

Partial<Omit<PhotoSpecMessages, "issues">> & { issues?: Partial<PhotoSpecMessages["issues"]> }—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Choose button is described by the spec; the hidden file input is removed from tab order
  • Status lines have text; icons are aria-hidden
  • Focus moves to the fix or choose button after reading

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Presets reflect the sources below and change often; portals may also check things this can't (glasses, expression)
  • Face checks need a face box from your detector
  • The canvas fix re-encodes the photo

Rules

Rules last verified:

Informational; check the official source. Confirmed: US visa JPEG, square 600–1200 px, ≤ 240 kB, compression ≤ 20:1; UPSC colour JPG named photo, 20–200 KB. SSC, NTA and NEET presets were not re-checked this round. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Helps prevent an exam photo being rejected after upload

Also known as

photo upload · upsc · ssc · neet · nta · passport photo · visa photo · image resize

Field type

Dependencies

Pairs well with