Skip to content

@luminaphoto/lumina-js


@luminaphoto/lumina-js / Core / Editor

Class: Editor ​

Direct WASM image editor for main thread usage

Core.Editor provides direct access to WASM image processing operations without Web Workers. It automatically handles WASM module initialization and provides proper enum conversions between client code and WASM.

Important: This editor runs on the main thread and requires explicit memory management. Always call dispose() when done to prevent memory leaks.

Example ​

typescript
import { createCoreEditor } from '@luminaphoto/lumina-js';

const editor = createCoreEditor({ licenseKey: 'YOUR_KEY' });
await editor.initialize();

await editor.loadImage(buffer, 'jpeg');
editor.applyBrightness(30);
editor.applyContrast(-10);

const { data } = editor.exportImage('jpeg', 95);

// Explicit cleanup required
editor.dispose();

Constructors ​

Constructor ​

ts
new Editor(config): Editor;

Create a new Core Editor instance

Parameters ​

ParameterTypeDescription
configCoreEditorConfigConfiguration options for the editor

Returns ​

Editor

Accessors ​

disposed ​

Get Signature ​

ts
get disposed(): boolean;

Check if the editor has been disposed

Returns ​

boolean

True if the editor has been disposed

Methods ​

applyBrightness() ​

ts
applyBrightness(brightness): void;

Apply brightness adjustment permanently

Parameters ​

ParameterTypeDescription
brightnessnumberBrightness adjustment (-100.0 to +100.0, where 0 is no change)

Returns ​

void

Throws ​

When brightness is outside valid range or editor not initialized


applyColorGrading() ​

ts
applyColorGrading(grading): void;

Apply color grading adjustment permanently

Parameters ​

ParameterTypeDescription
gradingColorGradingParamsColor grading parameters

Returns ​

void

Throws ​

When grading parameters are outside valid ranges or editor not initialized


applyContrast() ​

ts
applyContrast(contrast): void;

Apply contrast adjustment permanently

Parameters ​

ParameterTypeDescription
contrastnumberContrast adjustment value. Range: -100.0 to +100.0, where 0.0 is no change

Returns ​

void

Throws ​

When contrast is outside valid range or editor not initialized


applyExposure() ​

ts
applyExposure(exposure): void;

Apply exposure adjustment permanently

Parameters ​

ParameterTypeDescription
exposurenumberExposure adjustment in stops (-5.0 to +5.0)

Returns ​

void

Throws ​

When exposure is outside valid range or editor not initialized


applyHighlightsShadows() ​

ts
applyHighlightsShadows(
   highlights, 
   shadows, 
   midtones): void;

Apply highlights, shadows, and midtones adjustment permanently

Parameters ​

ParameterTypeDescription
highlightsnumberHighlights adjustment (-100.0 to 100.0)
shadowsnumberShadows adjustment (-100.0 to 100.0)
midtonesnumberMidtones adjustment (-100.0 to 100.0)

Returns ​

void

Throws ​

When parameters are outside valid ranges or editor not initialized


applySaturation() ​

ts
applySaturation(saturation): void;

Apply saturation adjustment permanently

Parameters ​

ParameterTypeDescription
saturationnumberSaturation adjustment (-100.0 to +100.0, where 0.0 is no change)

Returns ​

void

Throws ​

When saturation is outside valid range or editor not initialized


applyTemperature() ​

ts
applyTemperature(temperature, tint): void;

Apply color temperature and tint adjustment permanently

Parameters ​

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

Returns ​

void

Throws ​

When parameters are outside valid ranges or editor not initialized


applyTonalCurve() ​

ts
applyTonalCurve(curve): void;

Apply tonal curve adjustment permanently

Parameters ​

ParameterTypeDescription
curveTonalCurvePointsTonal curve control points

Returns ​

void

Throws ​

When curve parameters are invalid or editor not initialized


canRedo() ​

ts
canRedo(nodeType): boolean;

Check if redo is available for specified operation type

Parameters ​

ParameterTypeDescription
nodeTypeNodeTypeType of operation to check

Returns ​

boolean

True if redo is available for the specified operation type

Example ​

typescript
// Safely check before redoing
if (editor.canRedo(Shared.NodeType.Contrast)) {
  editor.redoOperation(Shared.NodeType.Contrast);
} else {
  console.log('No contrast operations to redo');
}

See ​

redoOperation Redo an operation of specified type


canUndo() ​

ts
canUndo(nodeType): boolean;

Check if undo is available for specified operation type

Parameters ​

ParameterTypeDescription
nodeTypeNodeTypeType of operation to check

Returns ​

boolean

True if undo is available for the specified operation type

Example ​

typescript
// Safely check before undoing
if (editor.canUndo(Shared.NodeType.Exposure)) {
  editor.undoOperation(Shared.NodeType.Exposure);
} else {
  console.log('No exposure operations to undo');
}

See ​

undoOperation Undo an operation of specified type


dispose() ​

ts
dispose(): void;

Dispose of the editor and clean up all WASM resources

Releases all WASM memory including images and editor instances. The editor cannot be used after calling this method. This is required to prevent memory leaks when using WASM objects.

Returns ​

void

Example ​

typescript
const editor = new Core.Editor();
await editor.loadImage(buffer, 'jpeg');
// ... use editor ...
editor.dispose(); // Required cleanup

exportImage() ​

ts
exportImage(format, quality?): ExportImageResult;

Export the processed image

Parameters ​

ParameterTypeDefault valueDescription
formatExportFormatundefinedExport format
qualitynumber100Quality setting for JPEG/WebP (1-100, default: 100)

Returns ​

ExportImageResult

Exported image data


getPreview() ​

ts
getPreview(): PreviewResult;

Get preview of current edits

Returns ​

PreviewResult

Preview image data


loadImage() ​

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

Load an image from binary data

Parameters ​

ParameterTypeDescription
bufferArrayBufferImage file data as ArrayBuffer
formatImageFormatImage format ('jpeg', 'png', 'webp', or 'raw')

Returns ​

Promise<LoadImageResult>

Promise that resolves with load result


previewBrightness() ​

ts
previewBrightness(brightness): PreviewResult;

Preview brightness adjustment without applying permanently

Parameters ​

ParameterTypeDescription
brightnessnumberBrightness adjustment (-100.0 to +100.0, where 0 is no change)

Returns ​

PreviewResult

Preview image data

Throws ​

When brightness is outside valid range or editor not initialized


previewColorGrading() ​

ts
previewColorGrading(grading): PreviewResult;

Preview color grading adjustment without applying permanently

Parameters ​

ParameterTypeDescription
gradingColorGradingParamsColor grading parameters

Returns ​

PreviewResult

Preview image data

Throws ​

When grading parameters are outside valid ranges or editor not initialized


previewContrast() ​

ts
previewContrast(contrast): PreviewResult;

Preview contrast adjustment without applying permanently

Parameters ​

ParameterTypeDescription
contrastnumberContrast adjustment value. Range: -100.0 to +100.0, where 0.0 is no change

Returns ​

PreviewResult

Preview image data

Throws ​

When contrast is outside valid range or editor not initialized


previewExposure() ​

ts
previewExposure(exposure): PreviewResult;

Preview exposure adjustment without applying permanently

Parameters ​

ParameterTypeDescription
exposurenumberExposure adjustment in stops (-5.0 to +5.0)

Returns ​

PreviewResult

Preview image data

Throws ​

When exposure is outside valid range or editor not initialized


previewHighlightsShadows() ​

ts
previewHighlightsShadows(
   highlights, 
   shadows, 
   midtones): PreviewResult;

Preview highlights, shadows, and midtones adjustment without applying permanently

Parameters ​

ParameterTypeDescription
highlightsnumberHighlights adjustment (-100.0 to 100.0)
shadowsnumberShadows adjustment (-100.0 to 100.0)
midtonesnumberMidtones adjustment (-100.0 to 100.0)

Returns ​

PreviewResult

Preview image data

Throws ​

When parameters are outside valid ranges or editor not initialized


previewSaturation() ​

ts
previewSaturation(saturation): PreviewResult;

Preview saturation adjustment without applying permanently

Parameters ​

ParameterTypeDescription
saturationnumberSaturation adjustment (-100.0 to +100.0, where 0.0 is no change)

Returns ​

PreviewResult

Preview image data

Throws ​

When saturation is outside valid range or editor not initialized


previewTemperature() ​

ts
previewTemperature(temperature, tint): PreviewResult;

Preview temperature and tint adjustment without applying permanently

Parameters ​

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

Returns ​

PreviewResult

Preview image data

Throws ​

When parameters are outside valid ranges or editor not initialized


previewTonalCurve() ​

ts
previewTonalCurve(curve): PreviewResult;

Preview tonal curve adjustment without applying permanently

Parameters ​

ParameterTypeDescription
curveTonalCurvePointsTonal curve control points

Returns ​

PreviewResult

Preview image data

Throws ​

When curve parameters are invalid or editor not initialized


redoOperation() ​

ts
redoOperation(nodeType): PreviewResult;

Redo the last undone operation of specified type

Parameters ​

ParameterTypeDescription
nodeTypeNodeTypeType of operation to redo

Returns ​

PreviewResult

Preview result after redo operation

Throws ​

When nothing to redo or editor not initialized

Example ​

typescript
// Check if redo is available before calling
if (editor.canRedo(Shared.NodeType.Brightness)) {
  const preview = editor.redoOperation(Shared.NodeType.Brightness);
}

See ​


undoOperation() ​

ts
undoOperation(nodeType): PreviewResult;

Undo the last operation of specified type

Parameters ​

ParameterTypeDescription
nodeTypeNodeTypeType of operation to undo

Returns ​

PreviewResult

Preview result after undo operation

Throws ​

When nothing to undo or editor not initialized

Example ​

typescript
// Check if undo is available before calling
if (editor.canUndo(Shared.NodeType.Brightness)) {
  const preview = editor.undoOperation(Shared.NodeType.Brightness);
}

See ​

Proprietary. All rights reserved.