Skip to content

@luminaphoto/lumina-js


@luminaphoto/lumina-js / Client / Editor

Class: Editor

Web Worker-based image editor for non-blocking UI integration

Client.Editor offloads all image processing to a Web Worker, keeping the main thread responsive. It provides automatic operation queuing via SmartOperationQueue (preview operations are cancelled when apply operations arrive) and linear undo/redo history via HistoryManager.

This is the recommended editor for browser applications. For direct WASM access on the main thread or inside a worker you control, use Core.Editor instead.

Example

typescript
import { createEditor, Shared } from '@luminaphoto/lumina-js';

const editor = createEditor({ workerPath: './worker.js' });
await editor.initialize();

const result = await editor.loadImage(buffer, 'jpeg');
console.log(`Loaded ${result.width}x${result.height}`);

// Preview while dragging a slider (cancellable)
await editor.previewBrightness(25);

// Commit the value
await editor.applyBrightness(25);

// Undo / redo
if (editor.canUndo()) {
  await editor.undo();
}

// Export full-resolution result
const exported = await editor.exportImage('jpeg', 95);

// Cleanup
await editor.dispose();

Constructors

Constructor

ts
new Editor(config): Editor;

Create a new Client Editor instance

Parameters

ParameterTypeDescription
configClientEditorConfigConfiguration options for the editor

Returns

Editor

Accessors

historyManager

Get Signature

ts
get historyManager(): HistoryManager;

Access the underlying history manager for advanced history inspection

Returns

HistoryManager


imageLoaded

Get Signature

ts
get imageLoaded(): boolean;

Whether an image has been loaded and is ready for editing

Returns

boolean


initialized

Get Signature

ts
get initialized(): boolean;

Whether the editor has been initialized and is ready for use

Returns

boolean


metadata

Get Signature

ts
get metadata(): LoadImageResult | null;

Metadata from the currently loaded image, or null if no image is loaded

Returns

LoadImageResult | null

Methods

applyAdjustments()

ts
applyAdjustments(adjustments): Promise<void>;

Apply multiple adjustments in a single batch, following the standard processing order

Applies only the adjustments that are present in the provided object. Temperature and tint are applied together. Highlights, shadows, and midtones are applied together. Each applied adjustment is recorded in the undo history.

Parameters

ParameterTypeDescription
adjustmentsPartial<ImageAdjustments>Partial set of image adjustments to apply

Returns

Promise<void>

Throws

If no image is loaded or any operation fails


applyBrightness()

ts
applyBrightness(brightness): Promise<void>;

Apply brightness adjustment permanently and record in history

Parameters

ParameterTypeDescription
brightnessnumberBrightness value (-100 to +100, 0 = no change)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyColorGrading()

ts
applyColorGrading(grading): Promise<void>;

Apply color grading adjustment permanently and record in history

Parameters

ParameterTypeDescription
gradingColorGradingParamsColor grading parameters for shadow, midtone, and highlight tinting

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyContrast()

ts
applyContrast(contrast): Promise<void>;

Apply contrast adjustment permanently and record in history

Parameters

ParameterTypeDescription
contrastnumberContrast value (-100 to +100, 0 = no change)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyExposure()

ts
applyExposure(exposure): Promise<void>;

Apply exposure adjustment permanently and record in history

Parameters

ParameterTypeDescription
exposurenumberExposure value in stops (-5.0 to +5.0, 0 = no change)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyHighlightsShadows()

ts
applyHighlightsShadows(
   highlights, 
   shadows, 
midtones): Promise<void>;

Apply highlights, shadows, and midtones adjustment permanently and record in history

Parameters

ParameterTypeDescription
highlightsnumberHighlights recovery (-100 to +100, 0 = no change)
shadowsnumberShadows recovery (-100 to +100, 0 = no change)
midtonesnumberMidtones adjustment (-100 to +100, 0 = no change)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applySaturation()

ts
applySaturation(saturation): Promise<void>;

Apply saturation adjustment permanently and record in history

Parameters

ParameterTypeDescription
saturationnumberSaturation value (-100 to +100, 0 = no change)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyTemperature()

ts
applyTemperature(temperature, tint): Promise<void>;

Apply color temperature and tint adjustment permanently and record in history

Parameters

ParameterTypeDescription
temperaturenumberColor temperature adjustment (-100 to +100)
tintnumberGreen-magenta tint adjustment (-100 to +100)

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


applyTonalCurve()

ts
applyTonalCurve(curve): Promise<void>;

Apply tonal curve adjustment permanently and record in history

Parameters

ParameterTypeDescription
curveTonalCurvePointsTonal curve control points defining the tone mapping

Returns

Promise<void>

Throws

If no image is loaded or the operation fails


canRedo()

ts
canRedo(): boolean;

Check whether a redo operation is available

Returns

boolean

True if there are undone operations that can be redone


canUndo()

ts
canUndo(): boolean;

Check whether an undo operation is available

Returns

boolean

True if there are operations that can be undone


dispose()

ts
dispose(): Promise<void>;

Dispose of the editor, terminating the Web Worker and releasing all resources

After calling dispose(), the editor instance cannot be reused. Always call this method when the editor is no longer needed to avoid resource leaks.

Returns

Promise<void>


exportImage()

ts
exportImage(format, quality?): Promise<ExportImageResult>;

Export the full-resolution processed image

Parameters

ParameterTypeDefault valueDescription
formatExportFormatundefinedOutput format ('jpeg', 'png', or 'webp')
qualitynumber100Compression quality for JPEG/WebP (1-100, default: 100)

Returns

Promise<ExportImageResult>

Encoded image data

Throws

If no image is loaded or export fails


getPreview()

ts
getPreview(): Promise<PreviewResult>;

Get a preview of the current edited state

Returns

Promise<PreviewResult>

Encoded preview image data

Throws

If no image is loaded or the editor is not initialized


initialize()

ts
initialize(): Promise<void>;

Initialize the editor by spawning a Web Worker and loading the WASM module

Returns

Promise<void>

Throws

If worker creation or WASM initialization fails


loadImage()

ts
loadImage(buffer, fileType): Promise<LoadImageResult>;

Load an image from binary data

Parameters

ParameterTypeDescription
bufferArrayBufferRaw image file data
fileTypeImageFormatImage format identifier

Returns

Promise<LoadImageResult>

Image dimensions and metadata extracted from the file

Throws

If the editor is not initialized or the image cannot be decoded


previewBrightness()

ts
previewBrightness(brightness): Promise<PreviewResult>;

Preview brightness adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
brightnessnumberBrightness value (-100 to +100, 0 = no change)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewColorGrading()

ts
previewColorGrading(grading): Promise<PreviewResult>;

Preview color grading adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
gradingColorGradingParamsColor grading parameters for shadow, midtone, and highlight tinting

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewContrast()

ts
previewContrast(contrast): Promise<PreviewResult>;

Preview contrast adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
contrastnumberContrast value (-100 to +100, 0 = no change)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewExposure()

ts
previewExposure(exposure): Promise<PreviewResult>;

Preview exposure adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
exposurenumberExposure value in stops (-5.0 to +5.0, 0 = no change)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewHighlightsShadows()

ts
previewHighlightsShadows(
   highlights, 
   shadows, 
midtones): Promise<PreviewResult>;

Preview highlights, shadows, and midtones adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
highlightsnumberHighlights recovery (-100 to +100, 0 = no change)
shadowsnumberShadows recovery (-100 to +100, 0 = no change)
midtonesnumberMidtones adjustment (-100 to +100, 0 = no change)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewSaturation()

ts
previewSaturation(saturation): Promise<PreviewResult>;

Preview saturation adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
saturationnumberSaturation value (-100 to +100, 0 = no change)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewTemperature()

ts
previewTemperature(temperature, tint): Promise<PreviewResult>;

Preview color temperature and tint adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
temperaturenumberColor temperature adjustment (-100 to +100)
tintnumberGreen-magenta tint adjustment (-100 to +100)

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


previewTonalCurve()

ts
previewTonalCurve(curve): Promise<PreviewResult>;

Preview tonal curve adjustment without committing (cancellable)

Parameters

ParameterTypeDescription
curveTonalCurvePointsTonal curve control points defining the tone mapping

Returns

Promise<PreviewResult>

Preview image data with the adjustment applied

Throws

If no image is loaded or the editor is not initialized


redo()

ts
redo(): Promise<PreviewResult>;

Redo the most recently undone operation and return an updated preview

Returns

Promise<PreviewResult>

Preview image data after the redo

Throws

If there is nothing to redo or the editor is not initialized


reset()

ts
reset(): Promise<PreviewResult>;

Reset the editor to the initial unedited state and return a fresh preview

Returns

Promise<PreviewResult>

Preview image data of the original unedited image

Throws

If no image is loaded or the editor is not initialized


undo()

ts
undo(): Promise<PreviewResult>;

Undo the most recent operation and return an updated preview

Returns

Promise<PreviewResult>

Preview image data after the undo

Throws

If there is nothing to undo or the editor is not initialized

Proprietary. All rights reserved.