Appearance
@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
const editor = new Core.Editor();
// Auto-initializes WASM on first operation
const image = await editor.loadImage(buffer, 'jpeg');
await editor.applyBrightness(0.3);
const result = await editor.exportImage('jpeg', 95);
// Explicit cleanup required
editor.dispose();Constructors
Constructor
ts
new Editor(config): Editor;Create a new Core Editor instance
Parameters
| Parameter | Type | Description |
|---|---|---|
config | CoreEditorConfig | Configuration 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
| Parameter | Type | Description |
|---|---|---|
brightness | number | Brightness 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
| Parameter | Type | Description |
|---|---|---|
grading | ColorGradingParams | Color 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
| Parameter | Type | Description |
|---|---|---|
contrast | number | Contrast 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
| Parameter | Type | Description |
|---|---|---|
exposure | number | Exposure 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
| Parameter | Type | Description |
|---|---|---|
highlights | number | Highlights adjustment (-100.0 to 100.0) |
shadows | number | Shadows adjustment (-100.0 to 100.0) |
midtones | number | Midtones 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
| Parameter | Type | Description |
|---|---|---|
saturation | number | Saturation 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
| Parameter | Type | Description |
|---|---|---|
temperature | number | Color temperature adjustment (-100 to +100 relative to base temperature) |
tint | number | Green-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
| Parameter | Type | Description |
|---|---|---|
curve | TonalCurvePoints | Tonal 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
| Parameter | Type | Description |
|---|---|---|
nodeType | NodeType | Type 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
| Parameter | Type | Description |
|---|---|---|
nodeType | NodeType | Type 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 cleanupexportImage()
ts
exportImage(format, quality?): ExportImageResult;Export the processed image
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
format | ExportFormat | undefined | Export format |
quality | number | 100 | Quality setting for JPEG/WebP (1-100, default: 100) |
Returns
Exported image data
getPreview()
ts
getPreview(): PreviewResult;Get preview of current edits
Returns
Preview image data
loadImage()
ts
loadImage(buffer, format): Promise<LoadImageResult>;Load an image from binary data
Parameters
| Parameter | Type | Description |
|---|---|---|
buffer | ArrayBuffer | Image file data as ArrayBuffer |
format | ImageFormat | Image 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
| Parameter | Type | Description |
|---|---|---|
brightness | number | Brightness adjustment (-100.0 to +100.0, where 0 is no change) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
grading | ColorGradingParams | Color grading parameters |
Returns
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
| Parameter | Type | Description |
|---|---|---|
contrast | number | Contrast adjustment value. Range: -100.0 to +100.0, where 0.0 is no change |
Returns
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
| Parameter | Type | Description |
|---|---|---|
exposure | number | Exposure adjustment in stops (-5.0 to +5.0) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
highlights | number | Highlights adjustment (-100.0 to 100.0) |
shadows | number | Shadows adjustment (-100.0 to 100.0) |
midtones | number | Midtones adjustment (-100.0 to 100.0) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
saturation | number | Saturation adjustment (-100.0 to +100.0, where 0.0 is no change) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
temperature | number | Color temperature adjustment (-100 to +100 relative to base temperature) |
tint | number | Green-magenta tint adjustment (-100 to +100) |
Returns
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
| Parameter | Type | Description |
|---|---|---|
curve | TonalCurvePoints | Tonal curve control points |
Returns
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
| Parameter | Type | Description |
|---|---|---|
nodeType | NodeType | Type of operation to redo |
Returns
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
- canRedo Check if redo is available for operation type
- undoOperation Undo an operation
undoOperation()
ts
undoOperation(nodeType): PreviewResult;Undo the last operation of specified type
Parameters
| Parameter | Type | Description |
|---|---|---|
nodeType | NodeType | Type of operation to undo |
Returns
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
- canUndo Check if undo is available for operation type
- redoOperation Redo an undone operation