---
doc:
  title: Photo Import and Face Tagging
guide:
  slug: photos
  brief: folder uploads, face boxes, portrait crops, optional face recognition, and confirmation
  description: >-
    Add a resumable photo-folder drop zone and a live face tagger to an app.
    Install the photo import workflow with detection, crop, embedding and
    review steps. Enable recognition in the space's Settings after
    agreeing to its terms. Confirm suggested people and fill portraits
    using the app's existing person records.
---

# Photo Import and Face Tagging

Add a folder drop zone to a photo app with `bindFaceImport`. Photos upload with
progress and resume if the page reconnects. Each finished upload starts a
workflow. The workflow finds face rectangles, saves JPEG portrait crops, and
puts the faces in a review queue.

## Folder import and review

Mount the importer where app editors can upload photos. Pass the component your
app uses for people and a function that reads each person's display name. The
example uses `individual{first, last, photo}`. Replace these names with the
words of your own app.

```js ignore
import store from './api/client.js'
import { bindFaceImport } from '@yaks/face/import'

const unmount = await bindFaceImport(document.querySelector('#photos'), {
  store,
  api: new URL('./api/', location.href),
  people: 'individual',
  label: ({ individual }) =>
    [individual.first, individual.last].filter(Boolean).join(' '),
  portrait: { component: 'individual', property: 'photo' },
})
```

The tagger draws face boxes on the photo and searches the app's people when you
select a box. Selecting a person confirms the tag. If recognition is enabled,
the closest confirmed matches appear first. After confirming a person, review
similar untagged faces from this and other photos. Reject any incorrect
suggestions before confirming the rest. Remove a tag to put the face back in the
review queue. An empty person portrait fills from the highest-scoring confirmed
crop. An existing portrait stays in place.

To tag faces on a single photo, use `bindFaceTagger` from `@yaks/ux/face-tagger`
with the same options and `photo: {eid, url, alt}`. Use the upload's returned
blob eid and URL. The mount functions return a cleanup function for when the
view closes.

## Recognition and consent

Detection and portrait crops are available in every space. Recognition is off
until a space owner enables it in Settings and accepts the terms shown there.
Before asking for recognition, obtain and document the required permissions for
the faces in the folder. The space setting is the owner's acknowledgement. Each
import still needs authorization for the photos it contains.
[Terms of service](https://yaks.app/terms#face-recognition)

Pass `authorized: true` to `bindFaceImport` only after the app's user explicitly
authorizes recognition for the selected folder. Import with the default options
for detection and portraits alone. Uploads keep their authorization mode when
they resume. The workflow computes suggested people from confirmed tags whenever
someone opens review. Confirmations and removals are recorded as the person who
performed them.

## Workflow and app data

The importer installs `photoRecipe()` from `@yaks/face/recipe` if the app does
not already hold it. Each imported photo's `face_import{authorized}` starts a
case. Steps write tool calls to `face_detect`, `face_crop` and, when authorized,
`face_embed`. A `face_review{face}` waits for the tagger's confirmation and
completes when the face belongs to a confirmed person.

`face{photo, box, score}` points at the original blob. `portrait{artifact}`
points at the crop at `./api/blob/<artifact>`. `identified{person, by, at}`
points at the app's person entity. To use the same steps from your own workflow,
upload a blob and write `importPhoto(eid, authorized)` from the recipe package.
The recipe assigns one case per blob address.

See [Files and Uploads](./files) for upload limits and resumable queues.

The guide's map is at <https://yaks.app/docs.md>.
