An element already present in the DOM. Passing
null/undefined, or an element that isn't in the DOM yet, throws.
See the KiriOptions fields for defaults.
Loads an image, replacing whatever was loaded before. EXIF orientation
(rotation + horizontal flip) is corrected automatically unless
useExifOrientation: false was passed to the constructor — only for
File/Blob sources, since a plain URL string can't be read for EXIF
data without an extra fetch.
A File (e.g. from a file input), a Blob, or a URL string.
Initial zoom/offset/rotation/flip.
A snapshot of the current state — mutating the returned object has no effect.
Sets the zoom to an absolute value, clamped to [minZoom, maxZoom].
No-op if movableFrame: true — the image never zooms in that mode.
Sets the pan offset to an absolute value (image-center offset from the
frame center, in stage pixels), clamped so the frame stays fully covered
by the rendered image. No-op if movableFrame: true — the image never
pans in that mode; see setFramePosition() instead.
Sets the frame's position to an absolute value (offset from stage
center, in stage pixels), clamped so the frame stays fully within the
image's fixed bounds. Only meaningful — and only takes effect — when
movableFrame: true; a no-op otherwise, since the frame always stays
centered in the default mode.
Reverts zoom/offset/rotation/flip/filters/framePosition to what they
were right after load() resolved (including any loadOptions passed
to it). No-op if nothing has been loaded yet.
Rotates relative to the current rotation, snapped to the nearest 90°.
No-op if rotatable: false was passed to the constructor.
Toggles horizontal flip. Always mirrors left-right as currently
displayed on screen, regardless of the current rotation — not the
image's own pre-rotation axes, so the visible effect stays "horizontal"
no matter how the image is rotated. No-op if flippable: false.
Toggles vertical flip. Always mirrors top-to-bottom as currently
displayed on screen, regardless of the current rotation. No-op if
flippable: false.
Resizes the frame. Also resizes the stage to match, if
autoSizeStage: true (the default) — except in movableFrame mode,
where the stage stays pinned to the fixed image's own size (see
fixedImageSize's doc comment) instead of following the frame; letting
the stage shrink along with the frame there would clip the (unchanged,
still full-size) image down to whatever's left, visually reading as the
picture itself shrinking even though its actual rendered size never
changes. Each axis is clamped to a 20px minimum.
Merges a partial update into the current filters (omitted fields are
left as they are). Numeric values are clamped to >= 0.
Renders the current crop. A circle or rounded-rectangle frame is a real clip in the output (transparent corners on PNG/WebP); either shape exported as JPEG warns and renders solid black corners instead, since JPEG has no alpha channel.
A data URL string (type: "base64", the default), a Blob, or an HTMLCanvasElement.
The current crop selection as a rectangle in the original, unrotated, unflipped source image's own pixel coordinates — for sending to a server that will crop the full-resolution original itself instead of uploading a client-re-encoded image. See CropRegion.
Exports the current crop as a blob, then uploads it — a default
FormData/fetch POST, or a custom uploader (per-call options.uploader
wins over the constructor's, which wins over the built-in default).
Subscribes to "change" — fires on every state update (drag/zoom/rotate/flip/filters), and once after load() resolves.
Unsubscribes a callback previously passed to on.
Tears the instance down: removes all pointer/wheel event listeners
(drag/zoom gestures), the resize-handle listener (if resizableFrame),
and the zoom-slider listener (if showZoomer); clears the container's
innerHTML, leaving an empty container element; and clears all
"change" listeners. Call this when you're done with an instance (e.g.
unmounting) to avoid leaking listeners.
An interactive image cropper attached to a plain DOM element. Drag to pan, zoom via wheel/pinch/an optional built-in slider, rotate in 90° steps, flip, apply filters, then export or upload the crop. With
movableFrame: true, this inverts: the image is fixed and the frame itself is what you drag/resize instead — seeKiriOptions.movableFrame.