Skip to main content
EditState holds every edit, so the same photo reopens exactly as it was saved, every edit still editable.

Example

state.json

How It Is Written

  • Every field is written, a default’s too: no turn is 0, no flip false, Auto, the filter, the frame and the list are null while off, no areas or annotations are [], an area’s or an annotation’s angle is 0 when it has no turn. A default changed in a later version never changes a state saved before it.
  • Any field may be left out when you write a state yourself. A field left out reads as its default, so a hand-written state can stay short. Only version and crop are required.
  • In the units the screen shows: adjustments −100 to 100 (Sharpness 0 to 100), intensity and strength 0 to 100, rotation in degrees.
  • Geometry in working px: the px of the size the editor works the photo at, onLoad’s size. That is the photo’s own size up to 16.7 MP, and its working copy’s past it.
  • Rounded without moving a px: dragged geometry keeps 6 decimals and the ratio is written whole.

Storing It

The state is plain JSON. Store it beside the file onProcess hands back, and pass it to state with the same photo to reopen the edit:
upload.ts
A state with another version, a value out of range or more than 64 areas is INVALID_STATE.

Fields

3
required
The shape’s version. The editor writes and reads 3. A state with another version is INVALID_STATE. A state with no version is read as a Pintura state.
object
required
The crop, in working px, and its ratio.
number
The turn, in degrees: its quarter turn kept within −180° to 180°, the straightening on top of it, so four turns write none. Left out, 0.
boolean
Mirrored left to right. Left out, false.
boolean
Mirrored top to bottom. Left out, false.
object
The adjustments set by hand, each −100 to 100 (sharpness 0 to 100). One left out is at 0.
object | null
Auto while it is on, null while off. It keeps the numbers the photo’s analysis gave, so a reopened photo draws from them without analyzing it again, and a later change to Auto never changes a saved edit.
object | null
The filter and its intensity. null: none.
object | null
The frame and its color. null: none.
object[]
The obfuscated areas, in working px. At most 64, as many as the Obfuscate tool draws. An area may reach past the photo’s edge: only the part over the photo is drawn.
object[]
The annotations: lines, rulers, texts and Numbers, shapes and lenses, in drawing order, a later one on top. Their points are in the same px as the crop. See Annotation fields.
object | null
The Numbers’ list, one block. null: no list. See Annotation fields.
{ width: number; height: number } | null
The output size, in output px. null while none is set: the crop draws at its own size. The output never passes 16.7 MP.
object
What the user changed of the host’s watermark and signature, never the image nor the host’s text. The editor writes both roles, each empty when nothing changed. A field a role leaves out is the host’s. A saved change for a mark the host no longer gives is kept and ignored.