@pixerate/editor 0.102.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/dist/agent/index.cjs +7 -7
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.js +7 -7
- package/dist/canvas/index.cjs +3 -3
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.js +4 -4
- package/dist/chunk-4X5MIVCE.js +8036 -0
- package/dist/chunk-4X5MIVCE.js.map +1 -0
- package/dist/chunk-6BU5WU4R.cjs +1 -0
- package/dist/chunk-6BU5WU4R.cjs.map +1 -0
- package/dist/{chunk-IB53LVGV.js → chunk-DS7KDKPX.js} +1 -1
- package/dist/{chunk-ZZOTHJ4K.cjs → chunk-PV42JITT.cjs} +1 -1
- package/dist/{chunk-ZZOTHJ4K.cjs.map → chunk-PV42JITT.cjs.map} +1 -1
- package/dist/chunk-XYBJKUAU.js +1 -0
- package/dist/chunk-XYBJKUAU.js.map +1 -0
- package/dist/chunk-ZID226ZG.cjs +8036 -0
- package/dist/chunk-ZID226ZG.cjs.map +1 -0
- package/dist/compositor-Bc3PNP3C.d.cts +835 -0
- package/dist/compositor-BsYYllvR.d.ts +835 -0
- package/dist/export-_m3Es4ru.d.cts +3154 -0
- package/dist/export-iMrop3Jm.d.ts +3154 -0
- package/dist/homography-CZ-tFjay.d.cts +50 -0
- package/dist/homography-Ctfjoc1b.d.ts +50 -0
- package/dist/image-editor/index.cjs +2873 -9450
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +31 -3150
- package/dist/image-editor/index.d.ts +31 -3150
- package/dist/image-editor/index.js +2550 -9127
- package/dist/image-editor/index.js.map +1 -1
- package/dist/mixer-C1M1Nua_.d.cts +282 -0
- package/dist/mixer-Cu5a9Bzd.d.ts +282 -0
- package/dist/paint/index.cjs +4 -3
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +3 -281
- package/dist/paint/index.d.ts +3 -281
- package/dist/paint/index.js +2 -1
- package/dist/paint-editor/index.cjs +4733 -0
- package/dist/paint-editor/index.cjs.map +1 -0
- package/dist/paint-editor/index.d.cts +1680 -0
- package/dist/paint-editor/index.d.ts +1680 -0
- package/dist/paint-editor/index.js +4733 -0
- package/dist/paint-editor/index.js.map +1 -0
- package/dist/raster/index.d.cts +6 -835
- package/dist/raster/index.d.ts +6 -835
- package/dist/{surface-DIA-XatS.d.cts → surface-BBJN9wxg.d.cts} +1 -1
- package/dist/{surface-DIA-XatS.d.ts → surface-BBJN9wxg.d.ts} +1 -1
- package/dist/tools/index.cjs +3 -3
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +3 -3
- package/dist/vector/index.d.cts +2 -1
- package/dist/vector/index.d.ts +2 -1
- package/dist/{warp-B8rAguzs.d.ts → warp-CWHZzE3x.d.ts} +2 -49
- package/dist/{warp-nYs2DPrx.d.cts → warp-D5jz_tN7.d.cts} +2 -49
- package/package.json +6 -1
- package/skills/README.md +1 -0
- package/skills/pixerate-image-editor/SKILL.md +14 -5
- package/skills/pixerate-paint-editor/SKILL.md +203 -0
- /package/dist/{chunk-IB53LVGV.js.map → chunk-DS7KDKPX.js.map} +0 -0
|
@@ -1,3136 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { P as PixelSurface, B as BlendMode, T as TiledSurface, R as RasterRect } from '../surface-DIA-XatS.js';
|
|
4
|
-
export { a as BLEND_MODES, b as BlendModeInfo, M as MaskSurface, c as Rgb, d as Rgba, S as SurfaceDraft, e as TILE, f as TILE_SHIFT, g as Tile, h as TileKey, i as blendChannel, j as blendImageData, k as blendLum, l as blendPixel, m as blendRgb, n as canvasCompositeOperation, o as collectTiles, p as contentBounds, q as emptySurface, r as fillRect, s as finishTile, t as isBlendMode, u as isSeparableBlendMode, v as mixPigment8, w as mixPigmentRgb, x as normalizeBlendMode, y as packRgba, z as readPixel, A as readRegion, C as setLum, D as solidSurface, E as surfaceBytes, F as surfaceFromPixels, G as surfacesEqual, H as tileCoord, I as tileKey, J as tileRect, K as tilesInRect, L as translateSurface, N as uniformTile, O as writeRegion } from '../surface-DIA-XatS.js';
|
|
5
|
-
import { Q as Quad, a as WarpMesh, V as Vec2, A as AffineMatrix, H as Homography, W as WarpStyle } from '../types-CwMPoRMU.js';
|
|
6
|
-
import { BrushSettings, MixerSettings, MixerLoad, StrokeCoverage, MixerTarget, MixerStroke, StrokeApply, StrokePoint } from '../paint/index.js';
|
|
7
|
-
export { CoverageMap, DEFAULT_BRUSH, DEFAULT_MIXER, Dab, DabWalker, EMPTY_MIXER_LOAD, MAX_BRUSH_SIZE, MIXER_DRAIN, MIXER_PICKUP_RATE, MIXING_MODELS, MixingModel, PIGMENT_BANDS, PIGMENT_LAMBDA_MIN, PIGMENT_LAMBDA_STEP, PIGMENT_WAVELENGTHS, Pigment, PigmentOptions, PigmentRgb, applyStrokeToTile, cleanMixer, coverageTileCoord, createPigment, createPigmentTools, dabCoverage, dabRect, lerpPigment, lerpPigmentInto, loadMixer, mixPigments, normalizeBrush, normalizeMixer, rasterizeDab, reflectanceToRgb, rgbToReflectance, setPigmentColor, smoothPoints, tipFalloff, tipReach, tipShape, walkDabs } from '../paint/index.js';
|
|
8
|
-
import { b as WarpPreset } from '../warp-B8rAguzs.js';
|
|
9
|
-
export { W as WARP_STYLES, a as WARP_STYLE_LABELS, c as applyHomography, B as boxQuad, d as dragWarpMeshPoint, e as evalWarpMesh, C as homographyFromAffine, l as homographyFromPoints, q as identityWarpMesh, D as invertHomography, p as pullWarpMesh, E as rectToQuad, h as resizeWarpMesh, u as warpMeshEditPoints, v as warpMeshGridCurves, x as warpMeshParamAt, A as warpPresetMesh } from '../warp-B8rAguzs.js';
|
|
1
|
+
import { a as ImageAdjustments, D as DepthMaskOptions, b as SerializedImageEditorState, A as AdjustmentKind, c as AdjustmentLayer, d as AdjustmentParamsMap, e as AdjustmentLayerMask, f as AdjustmentLayerOf, C as CurvePoint, H as HueRange, L as LevelsChannel, g as ImageEditorController, h as SelectionMask, i as SelectionMode, j as ColorDistance, R as RefineEdgeParams, k as ImagePoint, l as ImageLayer, m as CropBox, n as RasterMask, o as Annotation, p as AdjustmentLayerNode, q as AnnotationLayer, r as LayerFilter, s as PixelLayer, t as DevelopFilter, u as ImageTransform, v as ImageHistogram, w as ImageProjection, x as CompositorSources, y as LayerCompositor, z as SmartFilterStack, B as SmartFilter, E as SmartObjectLayer, F as SmartContents, G as SmartDocument, J as SmartPlacement, K as FreeTransformGeometry, M as LayerPlacement, N as FreeTransformMode, O as FreeTransformResult, Q as FreeTransformSession, T as FreeTransformInit, U as TransformAnchor } from '../export-iMrop3Jm.js';
|
|
2
|
+
export { V as AIResultOptions, W as AdjustmentLayerBase, X as AdjustmentLayerInit, Y as AdjustmentLayerUpdate, Z as AnnotationPlacement, _ as AnnotationType, $ as ArrowAnnotation, a0 as AspectRatio, a1 as BaseAnnotation, a2 as BlackWhiteParams, a3 as BlurFilter, a4 as CircleAnnotation, a5 as ColorBalanceParams, a6 as ColorBalanceTone, a7 as ColorRangeOptions, a8 as ColorRangeSample, a9 as CreateAnnotationPayload, aa as CropHandle, ab as CurvesParams, ac as DEFAULT_ADJUSTMENTS, ad as DEFAULT_DEPTH_MASK, ae as DEFAULT_REFINE_EDGE_PARAMS, af as DEFAULT_TRANSFORM, ag as DeserializeContext, ah as DevelopSettings, ai as EMPTY_DISTANCE, aj as ExportOptions, ak as FREE_TRANSFORM_CONTENTS, al as FREE_TRANSFORM_MODES, am as FillOptions, an as FreeTransformContent, ao as FreeTransformHost, ap as FreeTransformPreview, aq as GUIDED_FILTER_EPS, ar as GroupLayer, as as HISTOGRAM_BINS, at as HistogramChannel, au as HistoryEntryHandle, av as HueSaturationParams, aw as IMAGE_EDITOR_SCHEMA_VERSION, ax as ImageAnnotation, ay as ImageDimensions, az as ImageEditorAIHooks, I as ImageEditorAssetStore, aA as ImageEditorFit, aB as ImageEditorOptions, aC as ImageEditorRenderer, aD as ImageEditorState, aE as ImageEditorTool, aF as ImageLayerType, aG as InpaintHook, aH as InpaintOptions, aI as InvertParams, aJ as LAYERED_SCHEMA_VERSION, aK as LayerBase, aL as LayerBlendMode, aM as LayerFilterKind, aN as LayerLocation, aO as LayerMaskProps, aP as LayerOperationError, aQ as LayerProperties, aR as LayerSourcesHost, aS as LayerTarget, aT as LegacySerializedImageEditorState, aU as LevelsParams, aV as LineAnnotation, aW as MagicWandOptions, aX as MixerStrokeInit, aY as PSD_BLEND_KEYS, aZ as PaintOptions, a_ as PaintStrokeResult, a$ as PaintStrokeSession, b0 as PenAnnotation, b1 as PhotoFilterParams, b2 as PixelBuffer, b3 as PixelLayerInit, b4 as PosterizeParams, b5 as PsdChannel, b6 as PsdExportInput, P as PsdExportResult, b7 as PsdFile, b8 as PsdHeader, b9 as PsdImportOptions, ba as PsdImportResult, bb as PsdLayerMask, bc as PsdLayerRecord, bd as PsdLayerSummary, be as PsdRect, bf as PsdResource, bg as PsdSmartFilter, bh as PsdTaggedBlock, bi as PsdTreeNode, bj as RectAnnotation, bk as RemoveBackgroundHook, bl as RemoveBackgroundOptions, bm as RenderOptions, bn as SELECTION_MODES, bo as SELECTION_MODIFY_OPS, bp as SampleOptions, bq as SelectionChannel, br as SelectionCommandOptions, bs as SelectionModifyOp, bt as SerializeContext, bu as SerializedAdjustmentLayer, bv as SerializedAnnotationLayer, bw as SerializedGroupLayer, S as SerializedLayer, bx as SerializedLayerEffects, by as SerializedLayeredImageEditorState, bz as SerializedPattern, bA as SerializedPixelLayer, bB as SerializedRasterMask, bC as SerializedSelection, bD as SerializedSmartContents, bE as SerializedSmartFilter, bF as SerializedSmartObjectLayer, bG as ShapeSelectionOptions, bH as SmartFilterKind, bI as SmartObjectInfo, bJ as SmartPsdData, bK as StrokeInit, bL as StrokeTool, bM as TONE_RANGE_PRESETS, bN as TRANSFORM_ANCHORS, bO as TextAnnotation, bP as ThresholdParams, bQ as ToneRangePreset, bR as TransformParams, bS as TransformReadout, bT as VibranceParams, bU as ViewportMetrics, bV as addLayerEffect, bW as addLayerFilter, bX as adjustmentNodeAsLayer, bY as anchorPoint, bZ as applyImageProjectionToContext, b_ as applyParams, b$ as blurFilter, c0 as borderCoverage, c1 as boxMean, c2 as boxPointOf, c3 as buildLayerMaskPlanes, c4 as calculateCropDrag, c5 as canvasToImagePoint, c6 as clampCropToImage, c7 as colorRange, c8 as combineSelections, c9 as computeHistogram, ca as computeSelectionBounds, cb as contractCoverage, cc as cornersFromMatrix, cd as coverageToByte, ce as createSelectionMask, cf as decodeLayerChannel, cg as decodeLayerMask, ch as decodeMergedImage, ci as decodePngDataUrl, cj as decodeSelectionRle, ck as depthMaskAlpha, cl as describeTransform, cm as deserializeEffects, cn as deserializeLayer, co as deserializeLayers, cp as deserializePatterns, cq as deserializeSelection, cr as developFilter, cs as distanceTransform, ct as duplicateLayer, cu as edgeWidth, cv as ellipsePoints, cw as ellipseSelection, cx as encodeSelectionRle, cy as encodeSurface, cz as expandCoverage, cA as exportPsd, cB as featherCoverage, cC as flipCorners, cD as fullSelection, cE as geometryHomography, cF as getAnnotationBounds, cG as getCropCursor, cH as getRotatedSize, cI as getViewportMetrics, cJ as getViewportProjection, cK as globalImageCache, cL as greyMorphology, cM as groupLayers, cN as guidePlanes, cO as guidedFilterColor, cP as hasSurface, cQ as hasWarp, cR as hashMaskContent, cS as histogramPath, cT as hitTestAnnotation, cU as hitTestCrop, cV as hueRange, cW as identityTransform, cX as imageToCanvasPoint, cY as importPsd, cZ as invertSelection, c_ as isActiveFilter, c$ as isIdentityTransform, d0 as isQuarterTurnSwapped, d1 as isSelectionEmpty, d2 as isSelectionMode, d3 as isSpatialFilter, d4 as isTransformAnchor, d5 as isValidWarp, d6 as layerEffectsOf, d7 as layerMaskCoverage, d8 as layerMaskFromSelection, d9 as layerMaskKey, da as layerName, db as layerTree, dc as layerTypeLabel, dd as magicWand, de as mapCropHandle, df as matrixFromCorners, dg as matrixFromParams, dh as migrateSerializedImageEditorState, di as migrateToLayeredState, dj as modifySelection, dk as moveLayer, dl as newLayerId, dm as normalizeAngle, dn as normalizeFilter, dp as normalizeLayerMask, dq as normalizeRect, dr as normalizeRefineEdgeParams, ds as normalizeStoredAdjustments, dt as offsetLayer, du as parseBlend, dv as parseColor, dw as parseSelectionMode, dx as pixelLayerBounds, dy as pixelLayers, dz as placeLayer, dA as polygonCoverage, dB as polygonSelection, dC as presetWarp, dD as previewStep, dE as projectImagePoint, dF as projectImageRect, dG as projectMaskCoverage, dH as psdToLayers, dI as readPsd, dJ as rectSelection, dK as referencePoint, dL as refineCoverage, dM as refineEdgeHalo, dN as refineSelection, dO as removeLayer, dP as removeLayerEffect, dQ as removeLayerFilter, dR as requireLayer, dS as requireUnlocked, dT as resizePixels, dU as resizeSelection, dV as resolveExternalAssets, dW as runLayerFilters, dX as selectionArea, dY as selectionFromCoverage, dZ as selectionFromPixels, d_ as selectionToCoverage, d$ as selectionToPixels, e0 as selectionValueAt, e1 as serializeContents, e2 as serializeEffects, e3 as serializeLayer, e4 as serializeLayers, e5 as serializeLayersExternal, e6 as serializePatterns, e7 as serializeSelection, e8 as setLayerEffects, e9 as setLayerEffectsEnabled, ea as setLayerMask, eb as setLayerProperties, ec as shiftCoverage, ed as smartObjectLayers, ee as smoothCoverage, ef as srgb8ToLab, eg as toHex, eh as toneRange, ei as transformHomography, ej as transformMap, ek as transformedBox, el as transformedPoint, em as ungroupLayer, en as unionRect, eo as unprojectCanvasPoint, ep as updateLayerEffect, eq as updateLayerFilter, er as updateLayerMaskProps, es as withNewIds, et as writePsd } from '../export-iMrop3Jm.js';
|
|
10
3
|
import { b as LoadReport, J as JsonObject, f as MigrationStep } from '../migrate-iTlm3a8h.js';
|
|
4
|
+
import { B as BlendMode, P as PixelSurface, R as RasterRect } from '../surface-BBJN9wxg.js';
|
|
5
|
+
export { b as BLEND_MODES, d as BlendModeInfo, M as MaskSurface, e as Rgb, f as Rgba, S as SurfaceDraft, g as TILE, h as TILE_SHIFT, c as Tile, T as TileKey, a as TiledSurface, j as blendChannel, k as blendImageData, l as blendLum, m as blendPixel, n as blendRgb, o as canvasCompositeOperation, p as collectTiles, q as contentBounds, r as emptySurface, s as fillRect, t as finishTile, i as isBlendMode, u as isSeparableBlendMode, v as mixPigment8, w as mixPigmentRgb, x as normalizeBlendMode, y as packRgba, z as readPixel, A as readRegion, C as setLum, D as solidSurface, E as surfaceBytes, F as surfaceFromPixels, G as surfacesEqual, H as tileCoord, I as tileKey, J as tileRect, K as tilesInRect, L as translateSurface, N as uniformTile, O as writeRegion } from '../surface-BBJN9wxg.js';
|
|
11
6
|
import { a as AgentToolProvider, A as AgentTool } from '../registry-D-4fit9C.js';
|
|
7
|
+
import { j as LayerEffects, l as LayerEffectKind, i as LayerEffect, E as EffectPattern, I as Interpolation } from '../compositor-BsYYllvR.js';
|
|
8
|
+
export { B as BevelContour, m as BevelEmbossEffect, n as BevelStyle, o as BevelTechnique, p as BevelTexture, q as ColorOverlayEffect, r as CompositeCallOptions, s as CompositeStats, k as CompositorOptions, t as ContourPoint, D as DEFAULT_GLOBAL_LIGHT, u as DropShadowEffect, v as EffectContour, w as EffectFill, x as EffectGradient, y as EffectPatternRef, g as GlobalLight, z as GlowTechnique, A as GradientColorStop, F as GradientOpacityStop, H as GradientOverlayEffect, J as GradientStyle, K as INTERPOLATIONS, M as InnerGlowEffect, N as InnerShadowEffect, O as LAYER_EFFECT_KINDS, P as LayerEffectError, L as LayerLocks, Q as MAX_EFFECT_REACH, S as MAX_TRANSFORM_PIXELS, T as OuterGlowEffect, U as PatternOverlayEffect, V as PatternPlacement, W as PatternTile, X as ResampleOptions, Y as SatinEffect, Z as StrokeEffect, _ as StrokePosition, $ as TransformTooLargeError, a0 as blendTile, a1 as builtinPattern, a2 as builtinPatternIds, a3 as changedTiles, a4 as compositeSurfaceOver, a5 as defaultEffectGradient, a6 as defaultLayerEffect, a7 as effectColorHex, a8 as effectReach, a9 as effectsFingerprint, aa as effectsMargin, ab as effectsScale, ac as findLayer, ad as flattenLayers, ae as hasActiveEffects, af as hashNoise, ag as insertLayer, ah as isInterpolation, ai as isLayerEffectKind, aj as isLayerLocked, ak as keysWeight, al as layerEffectFields, am as layerEffectLabel, an as mapLayer, ao as mergeLayerEffect, ap as newEffectId, aq as normalizeLayerEffects, ar as parseEffectColor, as as reduceSurface, at as scaleLayerEffect, au as transformSurface, av as transformedBounds, aw as validateEffectGradient, ax as validateLayerEffect, ay as validateLayerEffects, az as warpSurface } from '../compositor-BsYYllvR.js';
|
|
12
9
|
import { b as CaptureSurface } from '../capture-wwNGaW05.js';
|
|
10
|
+
export { DIRECT_GAUSSIAN_MAX_SIGMA, DecodedPng, EffectRect, ZlibError, adler32, base64ToBytes, bytesToBase64, curveLut, decodePng, deflate, deflateRaw, encodePng, gaussianBlur, inflate, inflateRaw, isPng, parseDataUrl, pngDataUrl, renderLayerEffects } from '../raster/index.js';
|
|
11
|
+
import { a as MixerLoad, M as MixerSettings } from '../mixer-Cu5a9Bzd.js';
|
|
12
|
+
export { B as BrushSettings, C as CoverageMap, g as DEFAULT_BRUSH, h as DEFAULT_MIXER, D as Dab, i as DabWalker, E as EMPTY_MIXER_LOAD, b as MAX_BRUSH_SIZE, j as MIXER_DRAIN, k as MIXER_PICKUP_RATE, l as MIXING_MODELS, e as MixerStroke, d as MixerTarget, m as MixingModel, f as StrokeApply, c as StrokeCoverage, S as StrokePoint, n as applyStrokeToTile, o as cleanMixer, p as coverageTileCoord, q as dabCoverage, r as dabRect, s as loadMixer, t as normalizeBrush, u as normalizeMixer, v as rasterizeDab, w as smoothPoints, x as tipFalloff, y as tipReach, z as tipShape, A as walkDabs } from '../mixer-Cu5a9Bzd.js';
|
|
13
|
+
export { PIGMENT_BANDS, PIGMENT_LAMBDA_MIN, PIGMENT_LAMBDA_STEP, PIGMENT_WAVELENGTHS, Pigment, PigmentOptions, PigmentRgb, createPigment, createPigmentTools, lerpPigment, lerpPigmentInto, mixPigments, reflectanceToRgb, rgbToReflectance, setPigmentColor } from '../paint/index.js';
|
|
14
|
+
import { W as WarpStyle, a as WarpMesh, V as Vec2, Q as Quad } from '../types-CwMPoRMU.js';
|
|
15
|
+
export { A as AffineMatrix, H as Homography } from '../types-CwMPoRMU.js';
|
|
16
|
+
export { a as applyHomography, c as boxQuad, d as homographyFromAffine, h as homographyFromPoints, i as invertHomography, r as rectToQuad } from '../homography-Ctfjoc1b.js';
|
|
17
|
+
export { a as WARP_STYLES, b as WARP_STYLE_LABELS, W as WarpPreset, d as dragWarpMeshPoint, e as evalWarpMesh, j as identityWarpMesh, p as pullWarpMesh, g as resizeWarpMesh, l as warpMeshEditPoints, n as warpMeshGridCurves, o as warpMeshParamAt, u as warpPresetMesh } from '../warp-CWHZzE3x.js';
|
|
13
18
|
import '../schema-Di0CS6Pe.js';
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* selected), row-major over the whole source image in natural pixels — the same space as the
|
|
18
|
-
* crop box and annotations. Soft values are partial selection (feathered or anti-aliased edges).
|
|
19
|
-
*
|
|
20
|
-
* Treat a mask as immutable: every operation returns a new one, so history entries can share
|
|
21
|
-
* them without copying.
|
|
22
|
-
*/
|
|
23
|
-
interface SelectionMask {
|
|
24
|
-
readonly width: number;
|
|
25
|
-
readonly height: number;
|
|
26
|
-
readonly data: Uint8Array;
|
|
27
|
-
/** Bounding box of the non-zero coverage, or `null` when nothing is selected. */
|
|
28
|
-
readonly bounds: CropBox | null;
|
|
29
|
-
}
|
|
30
|
-
/** How a new selection combines with the current one. */
|
|
31
|
-
type SelectionMode = 'replace' | 'add' | 'subtract' | 'intersect';
|
|
32
|
-
declare const SELECTION_MODES: readonly SelectionMode[];
|
|
33
|
-
declare function isSelectionMode(value: unknown): value is SelectionMode;
|
|
34
|
-
/** Parses `replace|add|subtract|intersect`; anything else is `replace`. */
|
|
35
|
-
declare function parseSelectionMode(value: unknown): SelectionMode;
|
|
36
|
-
/** RGBA pixels, 8 bits per channel, straight alpha (an `ImageData` qualifies). */
|
|
37
|
-
interface PixelBuffer {
|
|
38
|
-
width: number;
|
|
39
|
-
height: number;
|
|
40
|
-
data: ArrayLike<number>;
|
|
41
|
-
}
|
|
42
|
-
/** Serialized selection: a run-length encoding of the 8-bit coverage. */
|
|
43
|
-
interface SerializedSelection {
|
|
44
|
-
width: number;
|
|
45
|
-
height: number;
|
|
46
|
-
/** `r1:` + base64 of (value byte, LEB128 run length) pairs. */
|
|
47
|
-
rle: string;
|
|
48
|
-
}
|
|
49
|
-
/** Bounding box of non-zero bytes. */
|
|
50
|
-
declare function computeSelectionBounds(width: number, height: number, data: ArrayLike<number>): CropBox | null;
|
|
51
|
-
/** Wraps coverage bytes (taken over, not copied) as a selection, computing its bounds. */
|
|
52
|
-
declare function createSelectionMask(width: number, height: number, data?: Uint8Array): SelectionMask;
|
|
53
|
-
/** Select › All. */
|
|
54
|
-
declare function fullSelection(width: number, height: number): SelectionMask;
|
|
55
|
-
declare function isSelectionEmpty(mask: SelectionMask | null | undefined): boolean;
|
|
56
|
-
/** Coverage at a pixel, 0..1 (0 outside the image). */
|
|
57
|
-
declare function selectionValueAt(mask: SelectionMask, x: number, y: number): number;
|
|
58
|
-
/** 8-bit value of a coverage (clamped and rounded; NaN → 0). */
|
|
59
|
-
declare function coverageToByte(v: number): number;
|
|
60
|
-
/** A selection from 0..1 coverage. */
|
|
61
|
-
declare function selectionFromCoverage(width: number, height: number, coverage: ArrayLike<number>): SelectionMask;
|
|
62
|
-
/** The selection's coverage as 0..1 floats. */
|
|
63
|
-
declare function selectionToCoverage(mask: SelectionMask): Float32Array;
|
|
64
|
-
/** Number of fully-or-partly selected pixels, weighted by coverage (Σ coverage). */
|
|
65
|
-
declare function selectionArea(mask: SelectionMask | null | undefined): number;
|
|
66
|
-
/**
|
|
67
|
-
* Combines `next` with `prev` by `mode` (8-bit, exact: combining a mask with itself is a no-op).
|
|
68
|
-
* Add is the maximum, Subtract `max(prev − next, 0)`, Intersect the minimum. A missing `prev`
|
|
69
|
-
* reads as nothing selected. Returns `null` when nothing remains selected.
|
|
70
|
-
*/
|
|
71
|
-
declare function combineSelections(prev: SelectionMask | null | undefined, next: SelectionMask, mode: SelectionMode): SelectionMask | null;
|
|
72
|
-
/** Select › Inverse. */
|
|
73
|
-
declare function invertSelection(mask: SelectionMask): SelectionMask;
|
|
74
|
-
/** Bilinear resample to another size (e.g. an AI mask returned at a different resolution). */
|
|
75
|
-
declare function resizeSelection(mask: SelectionMask, width: number, height: number): SelectionMask;
|
|
76
|
-
type SelectionChannel = 'alpha' | 'luminance' | 'red' | 'green' | 'blue';
|
|
77
|
-
/**
|
|
78
|
-
* A selection from an image: by default its luminance (white = selected, the usual convention
|
|
79
|
-
* of segmentation masks), or one channel. Partly transparent pixels count as black for
|
|
80
|
-
* luminance, so a mask PNG with transparency works either way.
|
|
81
|
-
*/
|
|
82
|
-
declare function selectionFromPixels(pixels: PixelBuffer, options?: {
|
|
83
|
-
channel?: SelectionChannel;
|
|
84
|
-
invert?: boolean;
|
|
85
|
-
threshold?: number;
|
|
86
|
-
}): SelectionMask;
|
|
87
|
-
/** The selection as RGBA pixels: grey (white = selected, opaque) or white with coverage as alpha. */
|
|
88
|
-
declare function selectionToPixels(mask: SelectionMask, as?: 'gray' | 'alpha'): {
|
|
89
|
-
width: number;
|
|
90
|
-
height: number;
|
|
91
|
-
data: Uint8ClampedArray;
|
|
92
|
-
};
|
|
93
|
-
/** Run-length encodes coverage bytes: `r1:` + base64 of (value, LEB128 run length) pairs. */
|
|
94
|
-
declare function encodeSelectionRle(data: Uint8Array): string;
|
|
95
|
-
/** Decodes {@link encodeSelectionRle}; throws unless the runs cover exactly `length` bytes. */
|
|
96
|
-
declare function decodeSelectionRle(rle: string, length: number): Uint8Array;
|
|
97
|
-
declare function serializeSelection(mask: SelectionMask): SerializedSelection;
|
|
98
|
-
/** Restores a {@link SerializedSelection}; throws on damaged data. */
|
|
99
|
-
declare function deserializeSelection(value: unknown): SelectionMask;
|
|
100
|
-
/** A short, stable hash of a string or bytes (FNV-1a, 32-bit, hex) for cache keys. */
|
|
101
|
-
declare function hashMaskContent(content: string | Uint8Array): string;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The image editor's layer stack: pixel, adjustment, group and annotation layers in one ordered
|
|
105
|
-
* tree (bottom to top), all in document space (natural pixels of the document).
|
|
106
|
-
*
|
|
107
|
-
* Layer objects are immutable. Every change builds new objects along the path from the root to
|
|
108
|
-
* the changed layer and shares everything else, so undo history, the compositor's caches and
|
|
109
|
-
* serialization can compare layers by identity.
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
/** Blend modes of a layer; groups also accept `pass-through`. */
|
|
113
|
-
type LayerBlendMode = GroupBlendMode;
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* A layer mask (see the raster module's `RasterMask`) whose parametric `source` is a depth map:
|
|
117
|
-
* a depth mask is generated from it instead of painted, and its surface is unused.
|
|
118
|
-
*/
|
|
119
|
-
type RasterMask = RasterMask$1<DepthMaskOptions>;
|
|
120
|
-
interface LayerBase extends RasterLayerBase {
|
|
121
|
-
mask?: RasterMask;
|
|
122
|
-
}
|
|
123
|
-
/** The base sliders of the old document-level adjustments, as a filter on one layer. */
|
|
124
|
-
interface DevelopSettings {
|
|
125
|
-
brightness: number;
|
|
126
|
-
contrast: number;
|
|
127
|
-
saturation: number;
|
|
128
|
-
exposure: number;
|
|
129
|
-
temperature: number;
|
|
130
|
-
tint?: number;
|
|
131
|
-
/** Rendering process (see `ImageAdjustments.process`). */
|
|
132
|
-
process?: 1 | 2;
|
|
133
|
-
}
|
|
134
|
-
type DevelopFilter = {
|
|
135
|
-
id: string;
|
|
136
|
-
kind: 'develop';
|
|
137
|
-
enabled: boolean;
|
|
138
|
-
} & DevelopSettings;
|
|
139
|
-
/** Box blur of `radius` pixels (the old `adjustments.blur`), clamped at the canvas edges. */
|
|
140
|
-
interface BlurFilter {
|
|
141
|
-
id: string;
|
|
142
|
-
kind: 'blur';
|
|
143
|
-
enabled: boolean;
|
|
144
|
-
radius: number;
|
|
145
|
-
}
|
|
146
|
-
type LayerFilter = DevelopFilter | BlurFilter;
|
|
147
|
-
type LayerFilterKind = LayerFilter['kind'];
|
|
148
|
-
interface PixelLayer extends LayerBase, Omit<RasterPixelLayer, keyof RasterLayerBase> {
|
|
149
|
-
/** Live filters, applied bottom (first) to top before the mask and blend. */
|
|
150
|
-
filters?: LayerFilter[];
|
|
151
|
-
/**
|
|
152
|
-
* `'document'`: the pixels are the document's source image, unmodified (the Background of an
|
|
153
|
-
* opened image). Such a layer's `surface` is a placeholder; read its pixels through the
|
|
154
|
-
* controller. Painting it drops the flag.
|
|
155
|
-
*/
|
|
156
|
-
source?: 'document';
|
|
157
|
-
}
|
|
158
|
-
type AdjustmentLayerNode<K extends AdjustmentKind = AdjustmentKind> = {
|
|
159
|
-
[P in K]: LayerBase & {
|
|
160
|
-
type: 'adjustment';
|
|
161
|
-
kind: P;
|
|
162
|
-
params: AdjustmentParamsMap[P];
|
|
163
|
-
};
|
|
164
|
-
}[K];
|
|
165
|
-
interface GroupLayer extends Omit<LayerBase, 'blend'> {
|
|
166
|
-
type: 'group';
|
|
167
|
-
blend: LayerBlendMode;
|
|
168
|
-
/** Bottom to top. */
|
|
169
|
-
children: ImageLayer[];
|
|
170
|
-
/** UI only. */
|
|
171
|
-
collapsed?: boolean;
|
|
172
|
-
}
|
|
173
|
-
/** One annotation (pen, shape, arrow, text, image) as a layer, drawn by the annotation renderer. */
|
|
174
|
-
interface AnnotationLayer extends LayerBase {
|
|
175
|
-
type: 'annotation';
|
|
176
|
-
annotation: Annotation;
|
|
177
|
-
}
|
|
178
|
-
/** A nested layer document: the contents of a smart object made from layers (or an embedded PSD). */
|
|
179
|
-
interface SmartDocument {
|
|
180
|
-
/** Bottom to top, on a canvas of the contents' `width × height`. */
|
|
181
|
-
layers: ImageLayer[];
|
|
182
|
-
globalLight?: GlobalLight;
|
|
183
|
-
patterns?: EffectPattern[];
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* What a smart object places: raster pixels or a nested layer document, at their own pixel size.
|
|
187
|
-
* Immutable and shared: every instance placed from the same contents (duplicates, linked
|
|
188
|
-
* instances) holds the same `id`, and replacing or editing the contents updates them all.
|
|
189
|
-
*/
|
|
190
|
-
interface SmartContents {
|
|
191
|
-
/** Shared by linked instances; independent copies get a fresh one. */
|
|
192
|
-
id: string;
|
|
193
|
-
/** File name shown in the UI and written to PSD (`Layer 1.psb`, `photo.png`). */
|
|
194
|
-
name: string;
|
|
195
|
-
/** Pixel size of the contents (the placement maps `0..width × 0..height` into the document). */
|
|
196
|
-
width: number;
|
|
197
|
-
height: number;
|
|
198
|
-
/** `raster`: `raster` holds the pixels at (0, 0); `document`: `document` holds the layers. */
|
|
199
|
-
kind: 'raster' | 'document';
|
|
200
|
-
raster?: PixelSurface;
|
|
201
|
-
document?: SmartDocument;
|
|
202
|
-
/**
|
|
203
|
-
* The file the contents came from (a PSD's embedded file), written back by Export Contents and
|
|
204
|
-
* PSD export while the contents are unedited. Without `raster` / `document` the file could not
|
|
205
|
-
* be decoded here (a JPEG outside a browser): the layer keeps its rendered pixels, and changes
|
|
206
|
-
* that re-render it are refused until `prepareSmartObjects` decodes it.
|
|
207
|
-
*/
|
|
208
|
-
file?: {
|
|
209
|
-
bytes: Uint8Array;
|
|
210
|
-
type: string;
|
|
211
|
-
};
|
|
212
|
-
/** Linked to an external file (Photoshop `liFE`): only the embedded preview is held. */
|
|
213
|
-
linked?: {
|
|
214
|
-
path: string;
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Where a smart object's contents land, non-destructively: a warp in the contents' own pixels
|
|
219
|
-
* (optional) and then the map of the contents' rectangle onto `corners`. Every change re-renders
|
|
220
|
-
* from the contents, so repeated transforms never degrade.
|
|
221
|
-
*/
|
|
222
|
-
interface SmartPlacement {
|
|
223
|
-
/** Where the contents' corners land (top-left, top-right, bottom-right, bottom-left), document pixels. */
|
|
224
|
-
corners: Quad;
|
|
225
|
-
/** A Bézier warp over the contents' rectangle, control points in contents pixels (missing = none). */
|
|
226
|
-
warp?: WarpMesh | null;
|
|
227
|
-
/** Resampling (default bicubic). */
|
|
228
|
-
interpolation?: Interpolation;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* A Photoshop smart filter we do not model (Gaussian Blur, Camera Raw, …), kept from a PSD so it
|
|
232
|
-
* is listed, can be hidden, reordered or deleted, and is written back unchanged. It draws nothing.
|
|
233
|
-
*/
|
|
234
|
-
interface PsdSmartFilter {
|
|
235
|
-
id: string;
|
|
236
|
-
kind: 'psd';
|
|
237
|
-
enabled: boolean;
|
|
238
|
-
/** Photoshop's menu name (`Gaussian Blur...`). */
|
|
239
|
-
name: string;
|
|
240
|
-
/** The filter's `filterFX` item descriptor (versioned descriptor bytes), as read. */
|
|
241
|
-
data: Uint8Array;
|
|
242
|
-
}
|
|
243
|
-
/** One smart filter: a layer filter (or a kept PSD filter) with its own blending over the result below it. */
|
|
244
|
-
type SmartFilter = (LayerFilter | PsdSmartFilter) & {
|
|
245
|
-
/** How the filter's result blends with the result below it (Photoshop's Blending Options). */
|
|
246
|
-
blend: BlendMode;
|
|
247
|
-
/** 0..1 */
|
|
248
|
-
opacity: number;
|
|
249
|
-
};
|
|
250
|
-
type SmartFilterKind = SmartFilter['kind'];
|
|
251
|
-
/** The smart filter stack of a smart object. */
|
|
252
|
-
interface SmartFilterStack {
|
|
253
|
-
/** Layer › Smart Filter › Disable Smart Filters (each filter keeps its own `enabled`). */
|
|
254
|
-
enabled: boolean;
|
|
255
|
-
/** Bottom (applied first) to top. */
|
|
256
|
-
filters: SmartFilter[];
|
|
257
|
-
/**
|
|
258
|
-
* The one filter mask (document space): where the filtered result shows over the unfiltered
|
|
259
|
-
* contents. Missing reveals everywhere.
|
|
260
|
-
*/
|
|
261
|
-
mask?: RasterMask;
|
|
262
|
-
}
|
|
263
|
-
/** PSD data of a smart object kept for round trips (see the PSD module). */
|
|
264
|
-
interface SmartPsdData {
|
|
265
|
-
/** The placed-layer block as read (`SoLd`, `SoLE` or `PlLd`) and its key. */
|
|
266
|
-
key: string;
|
|
267
|
-
data: Uint8Array;
|
|
268
|
-
/** The instance id (`placed`), which keys the filter-effects cache. */
|
|
269
|
-
placed?: string;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* A smart object: `contents` placed through `placement`, then the smart filters. `surface` is the
|
|
273
|
-
* rendered result in document space (offset 0), rebuilt by every change to the contents,
|
|
274
|
-
* placement or filters; the compositor draws it like a pixel layer's pixels, and masks, effects,
|
|
275
|
-
* clipping and blend apply on top. Never paint into it: rasterize the layer first.
|
|
276
|
-
*/
|
|
277
|
-
interface SmartObjectLayer extends LayerBase {
|
|
278
|
-
type: 'smart';
|
|
279
|
-
contents: SmartContents;
|
|
280
|
-
placement: SmartPlacement;
|
|
281
|
-
smartFilters?: SmartFilterStack;
|
|
282
|
-
/** The rendered pixels (a cache of contents → placement → filters), document space. */
|
|
283
|
-
surface: PixelSurface;
|
|
284
|
-
/** Always (0, 0): a smart object moves through its placement. */
|
|
285
|
-
offset: {
|
|
286
|
-
x: number;
|
|
287
|
-
y: number;
|
|
288
|
-
};
|
|
289
|
-
/** 0..1, PSD "Fill" (missing = 1). */
|
|
290
|
-
fillOpacity?: number;
|
|
291
|
-
psd?: SmartPsdData;
|
|
292
|
-
}
|
|
293
|
-
type ImageLayer = PixelLayer | AdjustmentLayerNode | GroupLayer | AnnotationLayer | SmartObjectLayer;
|
|
294
|
-
type ImageLayerType = ImageLayer['type'];
|
|
295
|
-
/** Which part of the active layer painting targets (`filter-mask`: a smart object's filter mask). */
|
|
296
|
-
type LayerTarget = 'pixels' | 'mask' | 'filter-mask';
|
|
297
|
-
/** A fresh id with `prefix` (`layer`, `flt`, …). */
|
|
298
|
-
declare function newLayerId(prefix?: string): string;
|
|
299
|
-
type LayerLocation = LayerLocation$1<ImageLayer>;
|
|
300
|
-
|
|
301
|
-
/** The top-level and nested pixel layers. */
|
|
302
|
-
declare function pixelLayers(layers: readonly ImageLayer[]): PixelLayer[];
|
|
303
|
-
/** The develop filter of a pixel layer, if any. */
|
|
304
|
-
declare function developFilter(layer: PixelLayer): DevelopFilter | undefined;
|
|
305
|
-
declare function blurFilter(layer: PixelLayer): BlurFilter | undefined;
|
|
306
|
-
/** True for filters that change pixels (enabled, non-neutral). */
|
|
307
|
-
declare function isActiveFilter(f: LayerFilter): boolean;
|
|
308
|
-
/** True when a filter needs neighbouring pixels (it can't run tile by tile). */
|
|
309
|
-
declare function isSpatialFilter(f: LayerFilter): boolean;
|
|
310
|
-
/** Document-space bounds of a pixel layer's stored tiles, or `null`. */
|
|
311
|
-
declare function pixelLayerBounds(layer: PixelLayer, surface?: PixelSurface): CropBox | null;
|
|
312
|
-
/** Human label of a layer kind. */
|
|
313
|
-
declare function layerTypeLabel(type: ImageLayerType): string;
|
|
314
|
-
/** Layers whose pixels are a surface the compositor draws (pixel layers and smart objects). */
|
|
315
|
-
declare function hasSurface(layer: ImageLayer): layer is PixelLayer | SmartObjectLayer;
|
|
316
|
-
/** Every smart object in the stack (nested contents not included). */
|
|
317
|
-
declare function smartObjectLayers(layers: readonly ImageLayer[]): SmartObjectLayer[];
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Schema version 3 of the image editor document: the layer tree, with pixel layers and painted
|
|
321
|
-
* masks stored as PNG assets (cropped to their content and placed by position), plus the
|
|
322
|
-
* document-level crop, transform, output opacity, migrated blur and selection.
|
|
323
|
-
*
|
|
324
|
-
* Encoding is synchronous and exact (see `png.ts`). Each surface's encoding is memoised, so
|
|
325
|
-
* saving an unchanged layer again costs nothing.
|
|
326
|
-
*/
|
|
327
|
-
|
|
328
|
-
declare const LAYERED_SCHEMA_VERSION: 3;
|
|
329
|
-
/** A stored raster mask. Pixels: `asset` (grey PNG) placed at `x`, `y`; elsewhere `defaultValue`. */
|
|
330
|
-
interface SerializedRasterMask {
|
|
331
|
-
defaultValue: 0 | 255;
|
|
332
|
-
asset?: string;
|
|
333
|
-
x?: number;
|
|
334
|
-
y?: number;
|
|
335
|
-
density?: number;
|
|
336
|
-
feather?: number;
|
|
337
|
-
enabled?: boolean;
|
|
338
|
-
/** `false`: unlinked from the layer's pixels. */
|
|
339
|
-
linked?: boolean;
|
|
340
|
-
source?: DepthMaskOptions;
|
|
341
|
-
}
|
|
342
|
-
interface SerializedLayerBase {
|
|
343
|
-
id: string;
|
|
344
|
-
name: string;
|
|
345
|
-
visible: boolean;
|
|
346
|
-
opacity: number;
|
|
347
|
-
blend: string;
|
|
348
|
-
clipped?: boolean;
|
|
349
|
-
mask?: SerializedRasterMask;
|
|
350
|
-
locks?: LayerLocks;
|
|
351
|
-
effects?: SerializedLayerEffects;
|
|
352
|
-
}
|
|
353
|
-
/** A layer's effects: the effect list as JSON plus the PSD block they came from (base64). */
|
|
354
|
-
interface SerializedLayerEffects {
|
|
355
|
-
enabled: boolean;
|
|
356
|
-
scale?: number;
|
|
357
|
-
items: LayerEffect[];
|
|
358
|
-
psd?: {
|
|
359
|
-
key: string;
|
|
360
|
-
data: string;
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
interface SerializedPixelLayer extends SerializedLayerBase {
|
|
364
|
-
type: 'pixel';
|
|
365
|
-
/** Asset id of the pixels (RGBA PNG) placed at `x`, `y` in layer space; missing when empty. */
|
|
366
|
-
asset?: string;
|
|
367
|
-
x?: number;
|
|
368
|
-
y?: number;
|
|
369
|
-
offset: {
|
|
370
|
-
x: number;
|
|
371
|
-
y: number;
|
|
372
|
-
};
|
|
373
|
-
fillOpacity?: number;
|
|
374
|
-
filters?: LayerFilter[];
|
|
375
|
-
/** `'document'`: the pixels are the document's source image (no asset is stored). */
|
|
376
|
-
source?: 'document';
|
|
377
|
-
}
|
|
378
|
-
interface SerializedAdjustmentLayer extends SerializedLayerBase {
|
|
379
|
-
type: 'adjustment';
|
|
380
|
-
kind: string;
|
|
381
|
-
params: unknown;
|
|
382
|
-
}
|
|
383
|
-
interface SerializedGroupLayer extends SerializedLayerBase {
|
|
384
|
-
type: 'group';
|
|
385
|
-
children: SerializedLayer[];
|
|
386
|
-
collapsed?: boolean;
|
|
387
|
-
}
|
|
388
|
-
interface SerializedAnnotationLayer extends SerializedLayerBase {
|
|
389
|
-
type: 'annotation';
|
|
390
|
-
annotation: Annotation;
|
|
391
|
-
}
|
|
392
|
-
/** A smart filter as stored (a Photoshop filter keeps its descriptor as base64). */
|
|
393
|
-
type SerializedSmartFilter = (LayerFilter | (Omit<PsdSmartFilter, 'data'> & {
|
|
394
|
-
data: string;
|
|
395
|
-
})) & {
|
|
396
|
-
blend: string;
|
|
397
|
-
opacity: number;
|
|
398
|
-
};
|
|
399
|
-
interface SerializedSmartObjectLayer extends SerializedLayerBase {
|
|
400
|
-
type: 'smart';
|
|
401
|
-
/** Id of its entry in the document's `smartContents` (shared by linked instances). */
|
|
402
|
-
contents: string;
|
|
403
|
-
placement: {
|
|
404
|
-
corners: Array<{
|
|
405
|
-
x: number;
|
|
406
|
-
y: number;
|
|
407
|
-
}>;
|
|
408
|
-
warp?: WarpMesh;
|
|
409
|
-
interpolation?: string;
|
|
410
|
-
};
|
|
411
|
-
smartFilters?: {
|
|
412
|
-
enabled: boolean;
|
|
413
|
-
filters: SerializedSmartFilter[];
|
|
414
|
-
mask?: SerializedRasterMask;
|
|
415
|
-
};
|
|
416
|
-
/** The rendered pixels (RGBA PNG) at `x`, `y` in document space, so a load does not re-render. */
|
|
417
|
-
asset?: string;
|
|
418
|
-
x?: number;
|
|
419
|
-
y?: number;
|
|
420
|
-
fillOpacity?: number;
|
|
421
|
-
/** The PSD placed-layer block kept for round trips (base64). */
|
|
422
|
-
psd?: {
|
|
423
|
-
key: string;
|
|
424
|
-
data: string;
|
|
425
|
-
placed?: string;
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
/** Smart object contents as stored once per document, referenced by id from every instance. */
|
|
429
|
-
interface SerializedSmartContents {
|
|
430
|
-
id: string;
|
|
431
|
-
name: string;
|
|
432
|
-
width: number;
|
|
433
|
-
height: number;
|
|
434
|
-
kind: 'raster' | 'document';
|
|
435
|
-
/** Raster contents: RGBA PNG asset at (0, 0). */
|
|
436
|
-
asset?: string;
|
|
437
|
-
/** Document contents: the nested layers (their assets are in the document's `assets`). */
|
|
438
|
-
layers?: SerializedLayer[];
|
|
439
|
-
globalLight?: GlobalLight;
|
|
440
|
-
patterns?: SerializedPattern[];
|
|
441
|
-
/** The file the contents came from (base64), written back while unedited. */
|
|
442
|
-
file?: {
|
|
443
|
-
type: string;
|
|
444
|
-
data: string;
|
|
445
|
-
};
|
|
446
|
-
linked?: {
|
|
447
|
-
path: string;
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
type SerializedLayer = SerializedPixelLayer | SerializedAdjustmentLayer | SerializedGroupLayer | SerializedAnnotationLayer | SerializedSmartObjectLayer;
|
|
451
|
-
/** A version 3 document (layers). */
|
|
452
|
-
interface SerializedLayeredImageEditorState {
|
|
453
|
-
version: 3;
|
|
454
|
-
/** Canvas size in pixels. */
|
|
455
|
-
width: number;
|
|
456
|
-
height: number;
|
|
457
|
-
/** Bottom to top. */
|
|
458
|
-
layers: SerializedLayer[];
|
|
459
|
-
/** Asset id → PNG data URL (or an external reference, see `ImageEditorAssetStore`). */
|
|
460
|
-
assets: Record<string, string>;
|
|
461
|
-
activeLayerId: string | null;
|
|
462
|
-
crop: CropBox | null;
|
|
463
|
-
transform: ImageTransform;
|
|
464
|
-
/** Export alpha, 0..1. */
|
|
465
|
-
opacity: number;
|
|
466
|
-
/** Blur migrated from a v1 / v2 document with adjustment layers (runs after the layers). */
|
|
467
|
-
legacyOutputBlur?: number;
|
|
468
|
-
selection?: SerializedSelection;
|
|
469
|
-
/** Global light for layer effects (missing = 120°, 30°). */
|
|
470
|
-
globalLight?: GlobalLight;
|
|
471
|
-
/** The document's patterns for pattern effects, each an RGBA PNG data URL. */
|
|
472
|
-
patterns?: SerializedPattern[];
|
|
473
|
-
/** Contents of the smart objects (nested ones included), each stored once. */
|
|
474
|
-
smartContents?: SerializedSmartContents[];
|
|
475
|
-
}
|
|
476
|
-
interface SerializedPattern {
|
|
477
|
-
id: string;
|
|
478
|
-
name: string;
|
|
479
|
-
png: string;
|
|
480
|
-
}
|
|
481
|
-
declare function serializePatterns(patterns: readonly EffectPattern[]): SerializedPattern[];
|
|
482
|
-
/** Reads stored patterns, skipping (and reporting in `problems`) any that cannot be decoded. */
|
|
483
|
-
declare function deserializePatterns(raw: unknown, problems?: string[]): EffectPattern[];
|
|
484
|
-
interface EncodedSurface {
|
|
485
|
-
url: string;
|
|
486
|
-
x: number;
|
|
487
|
-
y: number;
|
|
488
|
-
}
|
|
489
|
-
/** The surface's content (non-default pixels) as a PNG data URL and its position, or `null`. */
|
|
490
|
-
declare function encodeSurface(surface: TiledSurface): EncodedSurface | null;
|
|
491
|
-
interface SerializeContext {
|
|
492
|
-
/** Adds an asset and returns its id. */
|
|
493
|
-
addAsset(url: string, hint: string): string;
|
|
494
|
-
/** Stores a smart object's contents (once per id). Without it, smart objects cannot be written. */
|
|
495
|
-
addContents?(contents: SmartContents): void;
|
|
496
|
-
}
|
|
497
|
-
declare function serializeEffects(effects: LayerEffects): SerializedLayerEffects;
|
|
498
|
-
/** Reads stored effects (leniently: broken effects are dropped), or `undefined`. */
|
|
499
|
-
declare function deserializeEffects(raw: unknown): LayerEffects | undefined;
|
|
500
|
-
declare function serializeLayer(layer: ImageLayer, ctx: SerializeContext): SerializedLayer;
|
|
501
|
-
/** Writes one contents entry (nested layers add their own assets and contents to `ctx`). */
|
|
502
|
-
declare function serializeContents(c: SmartContents, ctx: SerializeContext): SerializedSmartContents;
|
|
503
|
-
/**
|
|
504
|
-
* Serializes a layer tree with inline assets (asset ids are derived from layer ids). Smart object
|
|
505
|
-
* contents go to `smartContents`, once each (present only when there are smart objects).
|
|
506
|
-
*/
|
|
507
|
-
declare function serializeLayers(layers: readonly ImageLayer[]): {
|
|
508
|
-
layers: SerializedLayer[];
|
|
509
|
-
assets: Record<string, string>;
|
|
510
|
-
smartContents?: SerializedSmartContents[];
|
|
511
|
-
};
|
|
512
|
-
/**
|
|
513
|
-
* Where a host keeps layer pixels outside the JSON (`toJSON({ assets: 'external', store })`):
|
|
514
|
-
* `put` stores a PNG and returns a reference (a URL, a key) that `get` resolves later.
|
|
515
|
-
*/
|
|
516
|
-
interface ImageEditorAssetStore {
|
|
517
|
-
put(blob: Blob, info: {
|
|
518
|
-
id: string;
|
|
519
|
-
width: number;
|
|
520
|
-
height: number;
|
|
521
|
-
}): Promise<string>;
|
|
522
|
-
get(ref: string): Promise<Blob>;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Serializes a layer tree with its assets in `store`: each PNG is uploaded once per store (by
|
|
526
|
-
* content), and `assets` maps asset ids to the store's references.
|
|
527
|
-
*/
|
|
528
|
-
declare function serializeLayersExternal(layers: readonly ImageLayer[], store: ImageEditorAssetStore): Promise<{
|
|
529
|
-
layers: SerializedLayer[];
|
|
530
|
-
assets: Record<string, string>;
|
|
531
|
-
smartContents?: SerializedSmartContents[];
|
|
532
|
-
}>;
|
|
533
|
-
/**
|
|
534
|
-
* Turns external asset references back into data URLs through `store.get` (data URLs pass through),
|
|
535
|
-
* so the document loads like an inline one. References that fail are reported and left out.
|
|
536
|
-
*/
|
|
537
|
-
declare function resolveExternalAssets(assets: Record<string, string>, store: ImageEditorAssetStore | undefined, problems: string[]): Promise<Record<string, string>>;
|
|
538
|
-
interface DeserializeContext {
|
|
539
|
-
assets: Record<string, string>;
|
|
540
|
-
/** The stored `smartContents` table (smart objects reference it by id). */
|
|
541
|
-
smartContents?: unknown[];
|
|
542
|
-
/** Canvas size, for re-rendering a smart object stored without its pixels (default 1 × 1). */
|
|
543
|
-
canvas?: {
|
|
544
|
-
width: number;
|
|
545
|
-
height: number;
|
|
546
|
-
};
|
|
547
|
-
/** @internal Contents read so far by id (`null` while being read). */
|
|
548
|
-
contentsMemo?: Map<string, SmartContents | null>;
|
|
549
|
-
/** Decodes an asset (PNG data URL by default). Throw for an unusable asset. */
|
|
550
|
-
decodeAsset?(ref: string, channels: 1 | 4): {
|
|
551
|
-
width: number;
|
|
552
|
-
height: number;
|
|
553
|
-
data: ArrayLike<number>;
|
|
554
|
-
};
|
|
555
|
-
/** Problems found while reading (unknown kinds, broken assets); the rest still loads. */
|
|
556
|
-
problems: string[];
|
|
557
|
-
}
|
|
558
|
-
/** Decodes a PNG data URL into pixels of `channels` bytes each. */
|
|
559
|
-
declare function decodePngDataUrl(url: string, channels: 1 | 4): {
|
|
560
|
-
width: number;
|
|
561
|
-
height: number;
|
|
562
|
-
data: Uint8ClampedArray;
|
|
563
|
-
};
|
|
564
|
-
declare function deserializeLayer(raw: unknown, ctx: DeserializeContext): ImageLayer | null;
|
|
565
|
-
/** Reads a stored layer tree (layers that cannot be read are dropped and reported). */
|
|
566
|
-
declare function deserializeLayers(raw: unknown, ctx: DeserializeContext): ImageLayer[];
|
|
567
|
-
|
|
568
|
-
/** Display bins of a histogram. */
|
|
569
|
-
declare const HISTOGRAM_BINS = 256;
|
|
570
|
-
interface ImageHistogram {
|
|
571
|
-
/** 256-bin counts per channel. */
|
|
572
|
-
red: Uint32Array;
|
|
573
|
-
green: Uint32Array;
|
|
574
|
-
blue: Uint32Array;
|
|
575
|
-
/** 256-bin counts of Rec.709 luma `round(0.2126 R + 0.7152 G + 0.0722 B)` of the encoded values. */
|
|
576
|
-
luminance: Uint32Array;
|
|
577
|
-
/** Visible pixels counted (alpha > 0). Each counts once, partially transparent ones included. */
|
|
578
|
-
samples: number;
|
|
579
|
-
/** Fully transparent pixels, excluded from every bin. */
|
|
580
|
-
transparent: number;
|
|
581
|
-
/** Per channel (R, G, B): visible pixels at exactly 0. */
|
|
582
|
-
shadows: [number, number, number];
|
|
583
|
-
/** Per channel (R, G, B): visible pixels at exactly 255. */
|
|
584
|
-
highlights: [number, number, number];
|
|
585
|
-
/** Largest bin count over R, G, B and luminance (for scaling a plot). */
|
|
586
|
-
max: number;
|
|
587
|
-
}
|
|
588
|
-
interface PixelSource {
|
|
589
|
-
data: ArrayLike<number>;
|
|
590
|
-
width?: number;
|
|
591
|
-
height?: number;
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* Per-channel and luminance histograms of straight 8-bit RGBA pixels (an `ImageData` or anything
|
|
595
|
-
* with `data`), with clipping counts at the exact endpoints. Transparent pixels cannot add
|
|
596
|
-
* phantom peaks: they are counted separately and excluded.
|
|
597
|
-
*/
|
|
598
|
-
declare function computeHistogram(imageData: PixelSource): ImageHistogram;
|
|
599
|
-
type HistogramChannel = 'red' | 'green' | 'blue' | 'luminance';
|
|
600
|
-
/**
|
|
601
|
-
* An SVG path (`M … Z`) of one channel scaled into a `width` × `height` box, bins left to right,
|
|
602
|
-
* counts up from the bottom. `scale: 'sqrt'` (default) keeps small populations visible.
|
|
603
|
-
*/
|
|
604
|
-
declare function histogramPath(histogram: ImageHistogram, channel: HistogramChannel, width: number, height: number, options?: {
|
|
605
|
-
scale?: 'linear' | 'sqrt';
|
|
606
|
-
max?: number;
|
|
607
|
-
}): string;
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* The image editor's compositor: the raster engine (`@pixerate/editor/raster`) with the photo
|
|
611
|
-
* layer kinds plugged in. Adjustment layers filter what is below them (a run of adjacent ones is
|
|
612
|
-
* one float pass with one rounding at the end, exactly as `applyAdjustmentLayers` does, so a
|
|
613
|
-
* document migrated from adjustment layers renders identically); annotation layers are drawn by
|
|
614
|
-
* the host; pixel layers can carry develop and blur filters; masks can be depth masks.
|
|
615
|
-
*/
|
|
616
|
-
|
|
617
|
-
/** What the compositor needs from its host besides the layers. */
|
|
618
|
-
interface CompositorSources extends RasterSources {
|
|
619
|
-
/** The pixels of a pixel layer or smart object (resolves layers whose pixels are the document source). */
|
|
620
|
-
surfaceOf?(layer: PixelLayer | SmartObjectLayer): PixelSurface;
|
|
621
|
-
/**
|
|
622
|
-
* A parametric mask's depth map as RGBA at canvas size (the red channel is the depth), or
|
|
623
|
-
* `null` while it is unavailable (the mask then reveals everything).
|
|
624
|
-
*/
|
|
625
|
-
depthMap?(source: DepthMaskOptions): {
|
|
626
|
-
width: number;
|
|
627
|
-
height: number;
|
|
628
|
-
data: ArrayLike<number>;
|
|
629
|
-
} | null;
|
|
630
|
-
/** Draws one annotation into RGBA for `rect` (canvas hosts only); `null` when unavailable. */
|
|
631
|
-
rasterizeAnnotation?(annotation: Annotation, rect: CropBox): Uint8ClampedArray | null;
|
|
632
|
-
}
|
|
633
|
-
/** The `AdjustmentLayer` shape `applyAdjustmentLayers` evaluates, for a node (memoised). */
|
|
634
|
-
declare function adjustmentNodeAsLayer(node: AdjustmentLayerNode): AdjustmentLayer;
|
|
635
|
-
/** Evaluates a depth mask (see `applyDepthMask`) into one coverage byte per depth sample. */
|
|
636
|
-
declare function depthMaskAlpha(depth: number, options: DepthMaskOptions): number;
|
|
637
|
-
/** Runs layer filters (develop, blur) over RGBA `data` (`width × height`) in place, bottom first. */
|
|
638
|
-
declare function runLayerFilters(data: Uint8ClampedArray, width: number, height: number, filters: readonly LayerFilter[]): void;
|
|
639
|
-
/** The per-tile compositor for image editor layer stacks (see the raster module for the caches). */
|
|
640
|
-
declare class LayerCompositor extends RasterCompositor<ImageLayer, CompositorSources> {
|
|
641
|
-
constructor(options?: CompositorOptions);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
interface RenderOptions {
|
|
645
|
-
viewportWidth?: number;
|
|
646
|
-
viewportHeight?: number;
|
|
647
|
-
showCropOverlay?: boolean;
|
|
648
|
-
showSelectionOverlay?: boolean;
|
|
649
|
-
interactive?: boolean;
|
|
650
|
-
draftAnnotation?: Annotation | null;
|
|
651
|
-
draftCrop?: CropBox | null;
|
|
652
|
-
/** Viewport fit mode: 'contain' scales to full viewport bounds; 'margin' scales to 85% with 1.0 cap (default). */
|
|
653
|
-
fit?: ImageEditorFit;
|
|
654
|
-
/**
|
|
655
|
-
* How the active selection is shown: marching ants (default when there is a selection),
|
|
656
|
-
* a Quick Mask tint over the unselected area (default when `state.quickMask`), or not at all.
|
|
657
|
-
*/
|
|
658
|
-
selectionDisplay?: 'ants' | 'quickMask' | 'none';
|
|
659
|
-
/** Dash offset of the marching ants in screen pixels (animate it to make them march). */
|
|
660
|
-
antsOffset?: number;
|
|
661
|
-
/** A selection being drawn (e.g. a lasso), shown as a dashed outline in natural pixels. */
|
|
662
|
-
draftSelectionPath?: ImagePoint[] | null;
|
|
663
|
-
/** Document rectangles that are the only change since the last render (strokes); recomposites only there. */
|
|
664
|
-
dirty?: CropBox[];
|
|
665
|
-
/** The layer being edited: tiles keep a checkpoint below it so strokes and drags on it start there. */
|
|
666
|
-
checkpointLayerId?: string | null;
|
|
667
|
-
/** The paint tools' cursor: a circle of `diameter` px at (`x`, `y`) in natural pixels. */
|
|
668
|
-
brushCursor?: {
|
|
669
|
-
x: number;
|
|
670
|
-
y: number;
|
|
671
|
-
diameter: number;
|
|
672
|
-
} | null;
|
|
673
|
-
/** Free Transform's frame, handles and reference point in natural pixels (`FreeTransformTool.overlay()`). */
|
|
674
|
-
freeTransform?: {
|
|
675
|
-
outline: ImagePoint[];
|
|
676
|
-
handles: ImagePoint[];
|
|
677
|
-
reference: ImagePoint;
|
|
678
|
-
/** Warp mode: the mesh's grid lines as cubics, its anchors, and handles with their anchors. */
|
|
679
|
-
warp?: {
|
|
680
|
-
curves: ImagePoint[][];
|
|
681
|
-
anchors: ImagePoint[];
|
|
682
|
-
handles: Array<{
|
|
683
|
-
point: ImagePoint;
|
|
684
|
-
anchor: ImagePoint;
|
|
685
|
-
}>;
|
|
686
|
-
};
|
|
687
|
-
} | null;
|
|
688
|
-
}
|
|
689
|
-
/**
|
|
690
|
-
* Image Cache to avoid refetching HTMLImageElement objects repeatedly during re-renders.
|
|
691
|
-
*/
|
|
692
|
-
declare class ImageCache {
|
|
693
|
-
private cache;
|
|
694
|
-
get(src: string): Promise<HTMLImageElement>;
|
|
695
|
-
set(src: string, img: HTMLImageElement): void;
|
|
696
|
-
/** The loaded image for `src`, or `undefined` while it is not loaded yet. */
|
|
697
|
-
peek(src: string): HTMLImageElement | undefined;
|
|
698
|
-
clear(): void;
|
|
699
|
-
}
|
|
700
|
-
declare const globalImageCache: ImageCache;
|
|
701
|
-
/**
|
|
702
|
-
* Renders an image with all its transformations, filters, depth masks, and annotations
|
|
703
|
-
* to a target HTMLCanvasElement.
|
|
704
|
-
*/
|
|
705
|
-
declare class ImageEditorRenderer {
|
|
706
|
-
imageCache: ImageCache;
|
|
707
|
-
private cachedBaseCanvas;
|
|
708
|
-
private cachedBaseKey;
|
|
709
|
-
/**
|
|
710
|
-
* Histogram of the last viewport base render (after adjustments and layers, before
|
|
711
|
-
* annotations); `null` until a render with pixel access has happened.
|
|
712
|
-
*/
|
|
713
|
-
previewHistogram: ImageHistogram | null;
|
|
714
|
-
/** Called whenever the viewport base image is re-rendered with the new histogram. */
|
|
715
|
-
onPreviewHistogram?: (histogram: ImageHistogram | null) => void;
|
|
716
|
-
private sourceIds;
|
|
717
|
-
private nextSourceId;
|
|
718
|
-
/**
|
|
719
|
-
* The viewport's compositor. It only ever composites the viewport's stack, so its tile cache can
|
|
720
|
-
* trust dirty rectangles; exports use `exportCompositor`.
|
|
721
|
-
*/
|
|
722
|
-
compositor: LayerCompositor;
|
|
723
|
-
private exportCompositor;
|
|
724
|
-
/** How the host resolves layer pixels (set by the controller). */
|
|
725
|
-
layerSources?: LayerSourcesHost;
|
|
726
|
-
/**
|
|
727
|
-
* Debug / test switch: `'legacy'` forces the old base path for documents that still have the
|
|
728
|
-
* v1 / v2 shape, `'layers'` forces the compositor. Default: chosen per document.
|
|
729
|
-
*/
|
|
730
|
-
baseRoute: 'auto' | 'legacy' | 'layers';
|
|
731
|
-
/** Which path the last base render took. */
|
|
732
|
-
lastBaseRoute: 'legacy' | 'layers' | null;
|
|
733
|
-
private comp;
|
|
734
|
-
private depthMaps;
|
|
735
|
-
private assetVersion;
|
|
736
|
-
private scratch;
|
|
737
|
-
private cachedPostCanvas;
|
|
738
|
-
private cachedPostKey;
|
|
739
|
-
private cachedPostHistogram;
|
|
740
|
-
/**
|
|
741
|
-
* Helper to create a canvas element safely in browser/JSDOM.
|
|
742
|
-
*/
|
|
743
|
-
createCanvas(width: number, height: number): HTMLCanvasElement;
|
|
744
|
-
/**
|
|
745
|
-
* Renders the editor state onto a canvas (viewport or preview).
|
|
746
|
-
*/
|
|
747
|
-
renderToCanvas(targetCanvas: HTMLCanvasElement, imageSource: CanvasImageSource | string, state: ImageEditorState, options?: RenderOptions): Promise<void>;
|
|
748
|
-
/**
|
|
749
|
-
* Draws `region` of the source image with rotation/flip applied, then pixel adjustments
|
|
750
|
-
* and the depth mask (which receives the identical transform so it stays aligned).
|
|
751
|
-
*/
|
|
752
|
-
private renderBaseImage;
|
|
753
|
-
/** Which base path renders `state` (see `needsLegacyBase`). */
|
|
754
|
-
private chooseRoute;
|
|
755
|
-
/** Compositor sources for a `width × height` canvas: layer pixels, depth maps and annotation rasterizing. */
|
|
756
|
-
compositorSources(width: number, height: number): CompositorSources;
|
|
757
|
-
/** Loads what the compositor reads synchronously: depth maps (at canvas size) and annotation images. */
|
|
758
|
-
/** Loads depth maps and annotation images the compositor reads synchronously. */
|
|
759
|
-
prepareLayerAssets(layers: readonly ImageLayer[], width: number, height: number): Promise<void>;
|
|
760
|
-
/** Whether annotation layers can be rasterized here (a 2D canvas with pixel access). */
|
|
761
|
-
canRasterize(): boolean;
|
|
762
|
-
/** One annotation drawn into a tile-sized RGBA buffer at `rect` (document space), or `null` without a canvas. */
|
|
763
|
-
private rasterizeAnnotation;
|
|
764
|
-
private putTile;
|
|
765
|
-
/**
|
|
766
|
-
* Brings the viewport's composite canvas (document space, covering `region`) up to date,
|
|
767
|
-
* uploading only the tiles that changed since the last render.
|
|
768
|
-
*/
|
|
769
|
-
private updateComposite;
|
|
770
|
-
/**
|
|
771
|
-
* The base canvas of a layered document: the composite drawn through the base projection (crop,
|
|
772
|
-
* rotation, flips at scale 1), then output opacity and the migrated blur, which run in the output
|
|
773
|
-
* frame. Cached until the composite or those settings change.
|
|
774
|
-
*/
|
|
775
|
-
private layeredBase;
|
|
776
|
-
/** Output opacity then the migrated blur, in place on a base canvas; returns its histogram. */
|
|
777
|
-
private applyPost;
|
|
778
|
-
private publishHistogram;
|
|
779
|
-
private quickMaskCache;
|
|
780
|
-
private outlineCache;
|
|
781
|
-
/** Rubylith over the unselected area, drawn in natural image space. */
|
|
782
|
-
private drawQuickMask;
|
|
783
|
-
/** Marching ants: a white line under a black dashed one, one screen pixel wide. */
|
|
784
|
-
private drawAnts;
|
|
785
|
-
private drawDraftPath;
|
|
786
|
-
private getSourceId;
|
|
787
|
-
/**
|
|
788
|
-
* Draws an individual annotation onto the canvas.
|
|
789
|
-
*/
|
|
790
|
-
drawAnnotation(ctx: CanvasRenderingContext2D, ann: Annotation): Promise<void>;
|
|
791
|
-
/**
|
|
792
|
-
* Scalar fallback for blend modes the canvas cannot composite (Photoshop soft light, linear /
|
|
793
|
-
* vivid / pin light, hard mix, subtract, divide, darker / lighter colour, linear burn / dodge):
|
|
794
|
-
* draws the annotation on a same-size layer with the same transform, blends it into a copy of
|
|
795
|
-
* the target's pixels with `blendImageData`, and copies the result back inside the current clip.
|
|
796
|
-
*/
|
|
797
|
-
private drawAnnotationBlended;
|
|
798
|
-
private drawAnnotationContent;
|
|
799
|
-
/** Draws an annotation synchronously; an image annotation draws `img` (skipped when `null`). */
|
|
800
|
-
drawAnnotationShape(ctx: CanvasRenderingContext2D, ann: Annotation, img: CanvasImageSource | null): void;
|
|
801
|
-
/**
|
|
802
|
-
* Draws selection box around active annotation.
|
|
803
|
-
*/
|
|
804
|
-
private drawAnnotationSelection;
|
|
805
|
-
/** @deprecated Use the standalone `getAnnotationBounds` from the geometry module. */
|
|
806
|
-
getAnnotationBounds(ann: Annotation): {
|
|
807
|
-
x: number;
|
|
808
|
-
y: number;
|
|
809
|
-
width: number;
|
|
810
|
-
height: number;
|
|
811
|
-
};
|
|
812
|
-
/**
|
|
813
|
-
* Draws a rule-of-thirds crop grid overlay. All rectangles come from
|
|
814
|
-
* `getViewportMetrics`, i.e. the crop box projected through rotation/flip.
|
|
815
|
-
*/
|
|
816
|
-
private drawCropOverlay;
|
|
817
|
-
private drawFittedImage;
|
|
818
|
-
/**
|
|
819
|
-
* Performs an export render at exact pixel dimensions without zoom/pan viewport offsets.
|
|
820
|
-
*/
|
|
821
|
-
renderExport(imageSource: CanvasImageSource | string, state: ImageEditorState, options?: ExportOptions): Promise<HTMLCanvasElement>;
|
|
822
|
-
/**
|
|
823
|
-
* Generates a strictly binary mask canvas (white = area to regenerate, black = keep) in
|
|
824
|
-
* natural image pixel space of the current source image — the same space the crop box
|
|
825
|
-
* and annotations are stored in. Pair it with `toSourceDataURL()` for AI inpainting.
|
|
826
|
-
*/
|
|
827
|
-
renderMask(state: ImageEditorState, options?: {
|
|
828
|
-
useAnnotations?: boolean;
|
|
829
|
-
useCrop?: boolean;
|
|
830
|
-
useSelection?: boolean;
|
|
831
|
-
}): Promise<HTMLCanvasElement>;
|
|
832
|
-
private drawAnnotationMask;
|
|
833
|
-
}
|
|
834
|
-
/** What the renderer asks its host (the controller) about layer pixels. */
|
|
835
|
-
interface LayerSourcesHost {
|
|
836
|
-
surfaceOf(layer: PixelLayer): PixelSurface;
|
|
837
|
-
sourceIsOpaque(): boolean;
|
|
838
|
-
version(): string;
|
|
839
|
-
/** The document's global light for layer effects. */
|
|
840
|
-
globalLight?(): GlobalLight | undefined;
|
|
841
|
-
/** A document pattern for pattern effects (built-in patterns are found without it). */
|
|
842
|
-
pattern?(id: string): EffectPattern | null;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
interface ShapeSelectionOptions {
|
|
846
|
-
/** Partial coverage along the edge (default true). */
|
|
847
|
-
antiAlias?: boolean;
|
|
848
|
-
}
|
|
849
|
-
/**
|
|
850
|
-
* Even-odd polygon coverage over a `width × height` image: exact horizontal coverage on 4
|
|
851
|
-
* sub-rows per pixel row (1 without anti-aliasing, where a pixel is in when its centre is).
|
|
852
|
-
* Each sub-row only tests the edges that cross it (an active edge list over edges sorted by
|
|
853
|
-
* their top), so the cost is about pixels + edges × rows they span.
|
|
854
|
-
*/
|
|
855
|
-
declare function polygonCoverage(points: readonly ImagePoint[], width: number, height: number, antiAlias?: boolean): Float32Array;
|
|
856
|
-
/** Lasso / polygonal lasso: an even-odd polygon in natural image pixels. */
|
|
857
|
-
declare function polygonSelection(width: number, height: number, points: readonly ImagePoint[], options?: ShapeSelectionOptions): SelectionMask;
|
|
858
|
-
/** Normalises a rectangle with a negative width or height. */
|
|
859
|
-
declare function normalizeRect(rect: CropBox): CropBox;
|
|
860
|
-
/** Rectangular marquee. Fractional edges get partial coverage when anti-aliased. */
|
|
861
|
-
declare function rectSelection(width: number, height: number, rect: CropBox, options?: ShapeSelectionOptions): SelectionMask;
|
|
862
|
-
/** The ellipse inscribed in `rect` as a polygon fine enough that its chords stay within 0.05 px. */
|
|
863
|
-
declare function ellipsePoints(rect: CropBox): ImagePoint[];
|
|
864
|
-
/** Elliptical marquee inscribed in `rect`. */
|
|
865
|
-
declare function ellipseSelection(width: number, height: number, rect: CropBox, options?: ShapeSelectionOptions): SelectionMask;
|
|
866
|
-
|
|
867
|
-
/** How the magic wand measures colour difference. */
|
|
868
|
-
type ColorDistance = 'rgb' | 'perceptual';
|
|
869
|
-
interface MagicWandOptions {
|
|
870
|
-
/**
|
|
871
|
-
* 0..255. `rgb`: the largest per-channel difference in levels (alpha included), as
|
|
872
|
-
* Photoshop's wand. `perceptual`: CIE76 ΔE*ab, with 255 ≙ ΔE 100. Default 32.
|
|
873
|
-
*/
|
|
874
|
-
tolerance?: number;
|
|
875
|
-
/** Only the 4-connected region around the seed (default true); otherwise every similar pixel. */
|
|
876
|
-
contiguous?: boolean;
|
|
877
|
-
/** Soft one-pixel fringe on the edge (default true). */
|
|
878
|
-
antiAlias?: boolean;
|
|
879
|
-
/** Default `rgb`. */
|
|
880
|
-
distance?: ColorDistance;
|
|
881
|
-
}
|
|
882
|
-
/** CIE Lab (D65) of an 8-bit sRGB colour. */
|
|
883
|
-
declare function srgb8ToLab(r: number, g: number, b: number): [number, number, number];
|
|
884
|
-
/**
|
|
885
|
-
* Magic wand: pixels similar to the seed pixel. Contiguous mode is a scanline span fill with an
|
|
886
|
-
* explicit stack (fill a run, then scan the rows above and below it for new runs), so it is
|
|
887
|
-
* linear in the pixels visited and never recurses. An empty selection when the seed is outside.
|
|
888
|
-
*/
|
|
889
|
-
declare function magicWand(pixels: PixelBuffer, seed: ImagePoint, options?: MagicWandOptions): SelectionMask;
|
|
890
|
-
/** One Color Range sample: a colour (0..255 levels or `#rrggbb`) and, optionally, where it was picked. */
|
|
891
|
-
interface ColorRangeSample {
|
|
892
|
-
color: readonly [number, number, number] | string;
|
|
893
|
-
at?: ImagePoint;
|
|
894
|
-
}
|
|
895
|
-
interface ColorRangeOptions {
|
|
896
|
-
/** 0..200 levels (default 40): coverage falls off linearly to 0 at `fuzziness + 1` levels. */
|
|
897
|
-
fuzziness?: number;
|
|
898
|
-
/**
|
|
899
|
-
* Localized Color Clusters: a sample with a position also fades with distance from it,
|
|
900
|
-
* reaching 0 at this many pixels.
|
|
901
|
-
*/
|
|
902
|
-
localized?: number;
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Select › Color Range › Sampled Colors: each pixel takes its best match over the samples; a
|
|
906
|
-
* match falls off linearly with the largest per-channel difference, `1 − d / (fuzziness + 1)`.
|
|
907
|
-
* Transparent pixels are never selected.
|
|
908
|
-
*/
|
|
909
|
-
declare function colorRange(pixels: PixelBuffer, samples: readonly ColorRangeSample[], options?: ColorRangeOptions): SelectionMask;
|
|
910
|
-
type ToneRangePreset = 'shadows' | 'midtones' | 'highlights';
|
|
911
|
-
/** Luma bounds (0..255, Rec. 601) of the tonal presets. */
|
|
912
|
-
declare const TONE_RANGE_PRESETS: Record<ToneRangePreset, [number, number]>;
|
|
913
|
-
/**
|
|
914
|
-
* Select › Color Range › Shadows / Midtones / Highlights: pixels whose luma lies in `lo..hi` are
|
|
915
|
-
* selected; outside, selection falls off linearly to 0 over `falloff` levels.
|
|
916
|
-
*/
|
|
917
|
-
declare function toneRange(pixels: PixelBuffer, range: ToneRangePreset | readonly [number, number], falloff?: number): SelectionMask;
|
|
918
|
-
/**
|
|
919
|
-
* Select › Color Range › Reds … Magentas (`center` 0, 60, …, 300°): closeness of hue (full at
|
|
920
|
-
* the centre, none 60° away) × chroma × (2 − max), so neutrals are never selected.
|
|
921
|
-
*/
|
|
922
|
-
declare function hueRange(pixels: PixelBuffer, center: number): SelectionMask;
|
|
923
|
-
|
|
924
|
-
/** Distance reported for every pixel when there is no seed at all. */
|
|
925
|
-
declare const EMPTY_DISTANCE = 10000000000;
|
|
926
|
-
/**
|
|
927
|
-
* Exact Euclidean distance from every pixel centre to the nearest seed pixel centre (row-major
|
|
928
|
-
* `inside`, non-zero = seed): nearest seeds along columns, then the lower envelope of parabolas
|
|
929
|
-
* along rows (Felzenszwalb & Huttenlocher). Linear in the pixel count.
|
|
930
|
-
*/
|
|
931
|
-
declare function distanceTransform(inside: ArrayLike<number | boolean>, width: number, height: number): Float32Array;
|
|
932
|
-
/** Grows coverage (0..1) by `r` pixels: covered when the nearest selected centre is ≤ r away (fractional r → partial). */
|
|
933
|
-
declare function expandCoverage(m: ArrayLike<number>, w: number, h: number, r: number): Float32Array;
|
|
934
|
-
/** Shrinks coverage by `r` pixels (expands the inverse). */
|
|
935
|
-
declare function contractCoverage(m: ArrayLike<number>, w: number, h: number, r: number): Float32Array;
|
|
936
|
-
/**
|
|
937
|
-
* Select › Modify › Border: a soft band `2r` wide centred on the edge. A pixel `D` away (centre
|
|
938
|
-
* to centre) from the nearest pixel on the other side of the edge is selected `1 − (D − 1) / r`.
|
|
939
|
-
*/
|
|
940
|
-
declare function borderCoverage(m: ArrayLike<number>, w: number, h: number, r: number): Float32Array;
|
|
941
|
-
/**
|
|
942
|
-
* Select › Modify › Smooth: box average of radius `round(r)` with replicated edges, then
|
|
943
|
-
* re-thresholded at ½ — specks drop, corners round, straight edges stay hard.
|
|
944
|
-
*/
|
|
945
|
-
declare function smoothCoverage(m: ArrayLike<number>, w: number, h: number, r: number): Float32Array;
|
|
946
|
-
/** Select › Modify › Feather: Gaussian blur with σ = radius (as Photoshop), zero beyond the image. */
|
|
947
|
-
declare function featherCoverage(m: ArrayLike<number>, w: number, h: number, radius: number): Float32Array;
|
|
948
|
-
/** Grey dilation (`grow`) or erosion with a square of radius `r`, separable, O(1) per pixel. */
|
|
949
|
-
declare function greyMorphology(src: ArrayLike<number>, w: number, h: number, r: number, grow: boolean): Float32Array;
|
|
950
|
-
/**
|
|
951
|
-
* Grows (positive) or shrinks (negative) soft coverage by a fractional distance: whole pixels
|
|
952
|
-
* use one morphology, the remainder blends with the next pixel, so 0.3 px differs from 1 px.
|
|
953
|
-
*/
|
|
954
|
-
declare function shiftCoverage(src: ArrayLike<number>, w: number, h: number, amount: number): Float32Array;
|
|
955
|
-
type SelectionModifyOp = 'grow' | 'shrink' | 'feather' | 'border' | 'smooth';
|
|
956
|
-
declare const SELECTION_MODIFY_OPS: readonly SelectionModifyOp[];
|
|
957
|
-
/** Select › Modify (grow = Expand, shrink = Contract, feather, border, smooth) by `radius` pixels. */
|
|
958
|
-
declare function modifySelection(mask: SelectionMask, op: SelectionModifyOp, radius: number): SelectionMask;
|
|
959
|
-
|
|
960
|
-
/**
|
|
961
|
-
* Refine Edge / Select and Mask parameters (Photoshop's units). Refinement is edge-aware: within
|
|
962
|
-
* `radius` pixels of the mask's edge the coverage is re-estimated from the image with a colour
|
|
963
|
-
* guided filter (He et al.), so a coarse or misaligned mask (e.g. an AI segmentation) follows
|
|
964
|
-
* the real edges of the image.
|
|
965
|
-
*/
|
|
966
|
-
interface RefineEdgeParams {
|
|
967
|
-
/** Edge-detection band radius in pixels (0 = no edge detection). */
|
|
968
|
-
radius?: number;
|
|
969
|
-
/** Narrow the band where the image edge is sharp (hair stays soft, hard edges stay hard). */
|
|
970
|
-
smartRadius?: boolean;
|
|
971
|
-
/** 0..100: rounds jagged edges. */
|
|
972
|
-
smooth?: number;
|
|
973
|
-
/** Pixels of Gaussian softening. */
|
|
974
|
-
feather?: number;
|
|
975
|
-
/** 0..100: hardens soft edges. */
|
|
976
|
-
contrast?: number;
|
|
977
|
-
/** −100..100: moves the edge out (positive) or in; 100 % is `max(radius, 4)` pixels. */
|
|
978
|
-
shiftEdge?: number;
|
|
979
|
-
}
|
|
980
|
-
declare const DEFAULT_REFINE_EDGE_PARAMS: Required<RefineEdgeParams>;
|
|
981
|
-
/** Guided-filter regulariser (colour guide, samples in 0..1). */
|
|
982
|
-
declare const GUIDED_FILTER_EPS = 0.0001;
|
|
983
|
-
/** Clamped, complete parameters. */
|
|
984
|
-
declare function normalizeRefineEdgeParams(p?: RefineEdgeParams): Required<RefineEdgeParams>;
|
|
985
|
-
/** Pixels around the mask's content that refinement can read or write. */
|
|
986
|
-
declare function refineEdgeHalo(params?: RefineEdgeParams): number;
|
|
987
|
-
/** Box mean of radius `r` (window clipped to the image, divided by its pixel count). O(1) per pixel. */
|
|
988
|
-
declare function boxMean(src: ArrayLike<number>, w: number, h: number, r: number): Float32Array;
|
|
989
|
-
/**
|
|
990
|
-
* Guided filter with a colour guide (He et al., Eq. 19–21: `a_k = (Σ_k + εU)⁻¹ cov_k(I, p)`):
|
|
991
|
-
* filters `p` so that it is locally a linear function of the guide's colour, which makes the
|
|
992
|
-
* output's edges follow the guide's edges. `guide` is three planes of 0..1 values.
|
|
993
|
-
*/
|
|
994
|
-
declare function guidedFilterColor(guide: readonly [Float32Array, Float32Array, Float32Array], p: Float32Array, w: number, h: number, r: number, eps?: number): Float32Array;
|
|
995
|
-
/**
|
|
996
|
-
* Per-pixel transition width (pixels) of the guide's luminance: local range over local maximum
|
|
997
|
-
* gradient in a window of radius `r` (a sharp step gives about 2, a ramp of width L about L).
|
|
998
|
-
*/
|
|
999
|
-
declare function edgeWidth(guide: readonly [Float32Array, Float32Array, Float32Array], w: number, h: number, r: number): Float32Array;
|
|
1000
|
-
/**
|
|
1001
|
-
* Refines soft coverage `m` (`w × h`, 0..1) with `guide` (three 0..1 planes, required when
|
|
1002
|
-
* `radius > 0`): edge-aware re-estimation in a band around the edge, then smooth, feather,
|
|
1003
|
-
* contrast and shift edge, in that order.
|
|
1004
|
-
*/
|
|
1005
|
-
declare function refineCoverage(guide: readonly [Float32Array, Float32Array, Float32Array] | null, m: Float32Array, w: number, h: number, params?: RefineEdgeParams): Float32Array;
|
|
1006
|
-
/** Three 0..1 planes of a window of an RGBA buffer. */
|
|
1007
|
-
declare function guidePlanes(pixels: PixelBuffer, win?: CropBox): [Float32Array, Float32Array, Float32Array];
|
|
1008
|
-
/**
|
|
1009
|
-
* Refine Edge on a selection (or a coarse AI mask loaded as one) against `pixels` (the image,
|
|
1010
|
-
* same size). Work is confined to the mask's bounds grown by {@link refineEdgeHalo}, so a small
|
|
1011
|
-
* selection on a large image stays cheap.
|
|
1012
|
-
*/
|
|
1013
|
-
declare function refineSelection(pixels: PixelBuffer | null, mask: SelectionMask, params?: RefineEdgeParams): SelectionMask;
|
|
1014
|
-
|
|
1015
|
-
type CropHandle = 'nw' | 'ne' | 'se' | 'sw' | 'n' | 's' | 'e' | 'w' | 'inside' | null;
|
|
1016
|
-
interface ViewportMetrics {
|
|
1017
|
-
vpWidth: number;
|
|
1018
|
-
vpHeight: number;
|
|
1019
|
-
centerX: number;
|
|
1020
|
-
centerY: number;
|
|
1021
|
-
baseW: number;
|
|
1022
|
-
baseH: number;
|
|
1023
|
-
fitScale: number;
|
|
1024
|
-
renderW: number;
|
|
1025
|
-
renderH: number;
|
|
1026
|
-
totalScale: number;
|
|
1027
|
-
imageRect: {
|
|
1028
|
-
x: number;
|
|
1029
|
-
y: number;
|
|
1030
|
-
width: number;
|
|
1031
|
-
height: number;
|
|
1032
|
-
};
|
|
1033
|
-
cropRect: {
|
|
1034
|
-
x: number;
|
|
1035
|
-
y: number;
|
|
1036
|
-
width: number;
|
|
1037
|
-
height: number;
|
|
1038
|
-
} | null;
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* A complete description of the natural-image -> target mapping (see module comment).
|
|
1042
|
-
*/
|
|
1043
|
-
interface ImageProjection {
|
|
1044
|
-
/** Visible region in natural image pixels (crop box or full image). */
|
|
1045
|
-
region: CropBox;
|
|
1046
|
-
/** Rotation in degrees, normalised to [0, 360). */
|
|
1047
|
-
angle: number;
|
|
1048
|
-
flipH: boolean;
|
|
1049
|
-
flipV: boolean;
|
|
1050
|
-
/** Uniform scale from image pixels to target pixels. */
|
|
1051
|
-
scale: number;
|
|
1052
|
-
/** Target-space point that the centre of `region` maps to. */
|
|
1053
|
-
originX: number;
|
|
1054
|
-
originY: number;
|
|
1055
|
-
}
|
|
1056
|
-
/** Normalises any rotation in degrees to [0, 360). */
|
|
1057
|
-
declare function normalizeAngle(degrees: number): number;
|
|
1058
|
-
/** Whether the rotation swaps the displayed width and height. */
|
|
1059
|
-
declare function isQuarterTurnSwapped(transform: Pick<ImageTransform, 'rotate'>): boolean;
|
|
1060
|
-
/** Size of a region once rotated (bounding box for arbitrary angles). */
|
|
1061
|
-
declare function getRotatedSize(width: number, height: number, transform: Pick<ImageTransform, 'rotate'>): {
|
|
1062
|
-
width: number;
|
|
1063
|
-
height: number;
|
|
1064
|
-
};
|
|
1065
|
-
/** Maps a natural-image point to target space. */
|
|
1066
|
-
declare function projectImagePoint(pt: ImagePoint, p: ImageProjection): ImagePoint;
|
|
1067
|
-
/** Exact inverse of {@link projectImagePoint}. */
|
|
1068
|
-
declare function unprojectCanvasPoint(pt: ImagePoint, p: ImageProjection): ImagePoint;
|
|
1069
|
-
/**
|
|
1070
|
-
* Applies the projection to a 2D context so that subsequent drawing in natural image
|
|
1071
|
-
* pixels lands exactly where {@link projectImagePoint} says it does.
|
|
1072
|
-
*/
|
|
1073
|
-
declare function applyImageProjectionToContext(ctx: Pick<CanvasRenderingContext2D, 'translate' | 'scale' | 'rotate'>, p: ImageProjection): void;
|
|
1074
|
-
/** Projects an image-space rectangle and returns its target-space bounding box. */
|
|
1075
|
-
declare function projectImageRect(rect: CropBox, p: ImageProjection): {
|
|
1076
|
-
x: number;
|
|
1077
|
-
y: number;
|
|
1078
|
-
width: number;
|
|
1079
|
-
height: number;
|
|
1080
|
-
};
|
|
1081
|
-
/** Clamps a crop box to the image bounds. */
|
|
1082
|
-
declare function clampCropToImage(crop: CropBox, width: number, height: number): CropBox;
|
|
1083
|
-
/**
|
|
1084
|
-
* Returns the natural-image -> canvas projection used by the interactive viewport.
|
|
1085
|
-
*/
|
|
1086
|
-
declare function getViewportProjection(state: ImageEditorState, vpWidth: number, vpHeight: number, isActivelyCropping?: boolean, cropOverride?: CropBox | null): ImageProjection;
|
|
1087
|
-
/**
|
|
1088
|
-
* Calculates current viewport projection metrics for canvas <-> image coordinate mapping.
|
|
1089
|
-
* `cropRect` is the on-screen (rotated/flipped) rectangle of the crop box.
|
|
1090
|
-
*/
|
|
1091
|
-
declare function getViewportMetrics(state: ImageEditorState, vpWidth: number, vpHeight: number, isActivelyCropping?: boolean, cropOverride?: CropBox | null): ViewportMetrics;
|
|
1092
|
-
/**
|
|
1093
|
-
* Converts a point on the canvas (in internal canvas pixel space) to natural image pixel
|
|
1094
|
-
* space, accounting for zoom, pan, fit scale, crop offset, rotation and flips.
|
|
1095
|
-
*/
|
|
1096
|
-
declare function canvasToImagePoint(canvasPt: ImagePoint, state: ImageEditorState, vpWidth: number, vpHeight: number, isActivelyCropping?: boolean): ImagePoint;
|
|
1097
|
-
/**
|
|
1098
|
-
* Converts a point in natural image pixel space to internal canvas pixel space.
|
|
1099
|
-
* Exact inverse of {@link canvasToImagePoint}.
|
|
1100
|
-
*/
|
|
1101
|
-
declare function imageToCanvasPoint(imgPt: ImagePoint, state: ImageEditorState, vpWidth: number, vpHeight: number, isActivelyCropping?: boolean): ImagePoint;
|
|
1102
|
-
/**
|
|
1103
|
-
* Converts a crop handle in screen orientation to the equivalent edge/corner of the crop
|
|
1104
|
-
* box in natural image space, or the reverse with `toScreen = true`.
|
|
1105
|
-
*/
|
|
1106
|
-
declare function mapCropHandle(handle: CropHandle, transform: ImageTransform, toScreen?: boolean): CropHandle;
|
|
1107
|
-
/**
|
|
1108
|
-
* Hit-tests the crop box and its corner/edge handles given a canvas point.
|
|
1109
|
-
* The returned handle names the edge/corner of the crop box in natural image space
|
|
1110
|
-
* (what {@link calculateCropDrag} expects); use `getCropCursor(handle, state.transform)`
|
|
1111
|
-
* to obtain the matching on-screen cursor.
|
|
1112
|
-
*/
|
|
1113
|
-
declare function hitTestCrop(canvasPt: ImagePoint, state: ImageEditorState, vpWidth: number, vpHeight: number, handleThreshold?: number, cropOverride?: CropBox | null): CropHandle;
|
|
1114
|
-
/**
|
|
1115
|
-
* Returns CSS cursor style corresponding to a crop handle. Pass the current transform when
|
|
1116
|
-
* the handle comes from {@link hitTestCrop} (image space) so the cursor matches the
|
|
1117
|
-
* on-screen orientation under rotation/flip.
|
|
1118
|
-
*/
|
|
1119
|
-
declare function getCropCursor(handle: CropHandle, transform?: ImageTransform): string;
|
|
1120
|
-
/**
|
|
1121
|
-
* Calculates updated crop rectangle given a drag interaction.
|
|
1122
|
-
*/
|
|
1123
|
-
declare function calculateCropDrag(startCrop: CropBox, handle: CropHandle, startImgPt: ImagePoint, currentImgPt: ImagePoint, imgWidth: number, imgHeight: number, aspectRatio?: number | null, transform?: ImageTransform): CropBox;
|
|
1124
|
-
/**
|
|
1125
|
-
* Calculates bounding box of an annotation.
|
|
1126
|
-
*/
|
|
1127
|
-
declare function getAnnotationBounds(ann: Annotation): {
|
|
1128
|
-
x: number;
|
|
1129
|
-
y: number;
|
|
1130
|
-
width: number;
|
|
1131
|
-
height: number;
|
|
1132
|
-
};
|
|
1133
|
-
/**
|
|
1134
|
-
* Hit tests if a point in image space is within an annotation's bounds.
|
|
1135
|
-
*/
|
|
1136
|
-
declare function hitTestAnnotation(imgPt: ImagePoint, ann: Annotation, padding?: number): boolean;
|
|
1137
|
-
|
|
1138
|
-
/** Properties of a layer mask that leave its pixels intact (Photoshop's Properties › Masks). */
|
|
1139
|
-
interface LayerMaskProps {
|
|
1140
|
-
/** 0..1 (default 1): at 0.5 the masked-out areas still get half of the adjustment. */
|
|
1141
|
-
density?: number;
|
|
1142
|
-
/** Gaussian feather σ in pixels, 0..1000 (default 0). */
|
|
1143
|
-
feather?: number;
|
|
1144
|
-
/** Disabled masks are kept but ignored (the layer applies everywhere). Default true. */
|
|
1145
|
-
enabled?: boolean;
|
|
1146
|
-
/**
|
|
1147
|
-
* Layer masks only: `false` unlinks the mask, so moving or transforming the layer's pixels leaves
|
|
1148
|
-
* it in place. Default true. Adjustment-layer masks in canvas space ignore it.
|
|
1149
|
-
*/
|
|
1150
|
-
linked?: boolean;
|
|
1151
|
-
}
|
|
1152
|
-
/**
|
|
1153
|
-
* A clean layer mask from stored data, or `null` when it is unusable. Defaults are left out
|
|
1154
|
-
* (density 1, feather 0, enabled), so a plain mask serializes as `{width, height, rle}`. The
|
|
1155
|
-
* RLE is only decoded when rendering.
|
|
1156
|
-
*/
|
|
1157
|
-
declare function normalizeLayerMask(raw: unknown): AdjustmentLayerMask | null;
|
|
1158
|
-
/** A layer mask holding the selection's pixels (Add Layer Mask › Reveal Selection). */
|
|
1159
|
-
declare function layerMaskFromSelection(selection: SelectionMask, props?: LayerMaskProps): AdjustmentLayerMask;
|
|
1160
|
-
/** Applies property changes; `undefined` fields keep their value. */
|
|
1161
|
-
declare function updateLayerMaskProps(mask: AdjustmentLayerMask, props: LayerMaskProps): AdjustmentLayerMask;
|
|
1162
|
-
/** The mask's pixels as a selection (Load Selection from mask), or `null` when the data is damaged. */
|
|
1163
|
-
declare function decodeLayerMask(mask: AdjustmentLayerMask): SelectionMask | null;
|
|
1164
|
-
/** Cache key of everything about a mask that changes pixels. */
|
|
1165
|
-
declare function layerMaskKey(mask: AdjustmentLayerMask | undefined): string;
|
|
1166
|
-
/**
|
|
1167
|
-
* The mask's effective coverage (0..1, mask resolution): feathered (σ = feather, borders
|
|
1168
|
-
* replicated), then density applied as `1 − density·(1 − v)`. `null` for a disabled or damaged
|
|
1169
|
-
* mask, meaning "no mask".
|
|
1170
|
-
*/
|
|
1171
|
-
declare function layerMaskCoverage(mask: AdjustmentLayerMask): Float32Array | null;
|
|
1172
|
-
/**
|
|
1173
|
-
* Resamples mask coverage (natural-image aligned, any resolution) into a target raster drawn
|
|
1174
|
-
* through `projection` (the base canvas of the renderer: crop, rotation, flips): each target
|
|
1175
|
-
* pixel centre is unprojected to natural pixels and sampled bilinearly.
|
|
1176
|
-
*/
|
|
1177
|
-
declare function projectMaskCoverage(coverage: Float32Array, maskWidth: number, maskHeight: number, naturalWidth: number, naturalHeight: number, projection: ImageProjection, targetWidth: number, targetHeight: number): Float32Array;
|
|
1178
|
-
/**
|
|
1179
|
-
* Per-layer mask coverage for a render target, keyed by layer id; `undefined` when no layer has
|
|
1180
|
-
* an enabled, valid mask (so mask-free stacks take the exact same path as before).
|
|
1181
|
-
*/
|
|
1182
|
-
declare function buildLayerMaskPlanes(layers: readonly AdjustmentLayer[] | undefined, naturalWidth: number, naturalHeight: number, projection: ImageProjection, targetWidth: number, targetHeight: number): Map<string, Float32Array> | undefined;
|
|
1183
|
-
|
|
1184
|
-
/** A refused layer operation; the message says why and how to fix it. */
|
|
1185
|
-
declare class LayerOperationError extends Error {
|
|
1186
|
-
constructor(message: string);
|
|
1187
|
-
}
|
|
1188
|
-
/** Where a layer goes: above or below a layer (in its group), or at a position in a group. */
|
|
1189
|
-
interface LayerPlacement {
|
|
1190
|
-
/** Directly above this layer, in the same group. */
|
|
1191
|
-
aboveId?: string;
|
|
1192
|
-
/** Directly below this layer, in the same group. */
|
|
1193
|
-
belowId?: string;
|
|
1194
|
-
/** Inside this group (at `index`, default the top). */
|
|
1195
|
-
parentId?: string;
|
|
1196
|
-
/** Index in the parent's children (or the top level), 0 = bottom. */
|
|
1197
|
-
index?: number;
|
|
1198
|
-
}
|
|
1199
|
-
/** The layer with `id`, or a `LayerOperationError` listing the ids that exist. */
|
|
1200
|
-
declare function requireLayer(layers: readonly ImageLayer[], id: string): LayerLocation$1<ImageLayer>;
|
|
1201
|
-
/** Refuses when the layer is locked for `what` (and always for `all`). */
|
|
1202
|
-
declare function requireUnlocked(layer: ImageLayer, what: keyof LayerLocks, action: string): void;
|
|
1203
|
-
/** Inserts `layer` at `placement` (default: the top level at `defaultIndex`, or the top). */
|
|
1204
|
-
declare function placeLayer(layers: readonly ImageLayer[], layer: ImageLayer, placement?: LayerPlacement, defaultIndex?: number): ImageLayer[];
|
|
1205
|
-
/** Removes a layer (refused when it is locked). */
|
|
1206
|
-
declare function removeLayer(layers: readonly ImageLayer[], id: string): ImageLayer[];
|
|
1207
|
-
/** Moves a layer to `placement`. A group cannot go inside itself. Returns the new stack. */
|
|
1208
|
-
declare function moveLayer(layers: readonly ImageLayer[], id: string, placement: LayerPlacement): ImageLayer[];
|
|
1209
|
-
/** Every id in a subtree gets a fresh one (for duplicates). */
|
|
1210
|
-
declare function withNewIds<T extends ImageLayer>(layer: T): T;
|
|
1211
|
-
/** Duplicates a layer (and its children) directly above it. Returns the stack and the copy's id. */
|
|
1212
|
-
declare function duplicateLayer(layers: readonly ImageLayer[], id: string, name?: string): {
|
|
1213
|
-
layers: ImageLayer[];
|
|
1214
|
-
id: string;
|
|
1215
|
-
};
|
|
1216
|
-
/** Properties `setLayerProperties` changes. */
|
|
1217
|
-
interface LayerProperties {
|
|
1218
|
-
name?: string;
|
|
1219
|
-
visible?: boolean;
|
|
1220
|
-
/** 0..1 */
|
|
1221
|
-
opacity?: number;
|
|
1222
|
-
/** 0..1, pixel layers only. */
|
|
1223
|
-
fillOpacity?: number;
|
|
1224
|
-
blend?: LayerBlendMode;
|
|
1225
|
-
clipped?: boolean;
|
|
1226
|
-
locks?: LayerLocks;
|
|
1227
|
-
/** Groups only (UI state). */
|
|
1228
|
-
collapsed?: boolean;
|
|
1229
|
-
}
|
|
1230
|
-
/** Validates and applies property changes to one layer. */
|
|
1231
|
-
declare function setLayerProperties(layers: readonly ImageLayer[], id: string, props: LayerProperties): ImageLayer[];
|
|
1232
|
-
/**
|
|
1233
|
-
* Puts layers (siblings in one group or the top level) into a new group at the position of the
|
|
1234
|
-
* topmost one, keeping their order. Returns the stack and the group id.
|
|
1235
|
-
*/
|
|
1236
|
-
declare function groupLayers(layers: readonly ImageLayer[], ids: string[], name?: string): {
|
|
1237
|
-
layers: ImageLayer[];
|
|
1238
|
-
id: string;
|
|
1239
|
-
};
|
|
1240
|
-
/** Replaces a group by its children (the group's own opacity, blend and mask are dropped). */
|
|
1241
|
-
declare function ungroupLayer(layers: readonly ImageLayer[], id: string): {
|
|
1242
|
-
layers: ImageLayer[];
|
|
1243
|
-
ids: string[];
|
|
1244
|
-
};
|
|
1245
|
-
/** Sets a pixel layer's offset (refused when its position is locked). An unlinked mask stays in place. */
|
|
1246
|
-
declare function offsetLayer(layers: readonly ImageLayer[], id: string, offset: {
|
|
1247
|
-
x: number;
|
|
1248
|
-
y: number;
|
|
1249
|
-
}): ImageLayer[];
|
|
1250
|
-
/** Sets or removes (`null`) a layer's mask. */
|
|
1251
|
-
declare function setLayerMask(layers: readonly ImageLayer[], id: string, mask: RasterMask | null): ImageLayer[];
|
|
1252
|
-
/** A clean filter from loose input (for tools and the UI). */
|
|
1253
|
-
declare function normalizeFilter(raw: Partial<LayerFilter> & {
|
|
1254
|
-
kind: LayerFilter['kind'];
|
|
1255
|
-
}, id?: string): LayerFilter;
|
|
1256
|
-
/** Adds a filter on top of a pixel layer's filters. A layer has at most one filter of each kind. */
|
|
1257
|
-
declare function addLayerFilter(layers: readonly ImageLayer[], id: string, filter: LayerFilter): ImageLayer[];
|
|
1258
|
-
/** Changes one filter of a pixel layer (`changes` merged and validated). */
|
|
1259
|
-
declare function updateLayerFilter(layers: readonly ImageLayer[], id: string, filterId: string, changes: Record<string, unknown>): ImageLayer[];
|
|
1260
|
-
declare function removeLayerFilter(layers: readonly ImageLayer[], id: string, filterId: string): ImageLayer[];
|
|
1261
|
-
/** A layer's effects, or an empty, enabled list when it has none. */
|
|
1262
|
-
declare function layerEffectsOf(layer: ImageLayer): LayerEffects;
|
|
1263
|
-
/** Replaces a layer's effects (validated); `null` or an empty list without a PSD block removes them. */
|
|
1264
|
-
declare function setLayerEffects(layers: readonly ImageLayer[], id: string, effects: LayerEffects | null): ImageLayer[];
|
|
1265
|
-
/**
|
|
1266
|
-
* Adds an effect of `kind` (Photoshop's defaults with `params` applied) to a layer's effects, at
|
|
1267
|
-
* `index` in the list (default: the end; the first listed of a kind is on top). Returns the stack
|
|
1268
|
-
* and the new effect.
|
|
1269
|
-
*/
|
|
1270
|
-
declare function addLayerEffect(layers: readonly ImageLayer[], id: string, kind: LayerEffectKind, params?: Record<string, unknown>, index?: number): {
|
|
1271
|
-
layers: ImageLayer[];
|
|
1272
|
-
effect: LayerEffect;
|
|
1273
|
-
};
|
|
1274
|
-
/** Changes one effect (only the given fields; nested objects replace whole, `null` removes an optional one). */
|
|
1275
|
-
declare function updateLayerEffect(layers: readonly ImageLayer[], id: string, effectId: string, changes: Record<string, unknown>): ImageLayer[];
|
|
1276
|
-
declare function removeLayerEffect(layers: readonly ImageLayer[], id: string, effectId: string): ImageLayer[];
|
|
1277
|
-
/** Sets the master switch and, when given, Scale Effects (0.01..10, 1 = 100 %). */
|
|
1278
|
-
declare function setLayerEffectsEnabled(layers: readonly ImageLayer[], id: string, enabled: boolean, scale?: number): ImageLayer[];
|
|
1279
|
-
/** A blend mode check for tools. */
|
|
1280
|
-
declare function parseBlend(value: unknown, allowPassThrough?: boolean): BlendMode | 'pass-through' | undefined;
|
|
1281
|
-
/** The union of two rectangles (either may be null). */
|
|
1282
|
-
declare function unionRect(a: CropBox | null, b: CropBox | null): CropBox | null;
|
|
1283
|
-
|
|
1284
|
-
interface PlaneLayout {
|
|
1285
|
-
planes: number;
|
|
1286
|
-
width: number;
|
|
1287
|
-
height: number;
|
|
1288
|
-
depth: number;
|
|
1289
|
-
/** PSB: RLE row counts are 4 bytes. */
|
|
1290
|
-
psb: boolean;
|
|
1291
|
-
}
|
|
1292
|
-
/** Decodes planar channel data (`planes` planes of `height` rows each). */
|
|
1293
|
-
declare function decodePlanes(compression: number, data: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
1294
|
-
/** RLE-encodes planar data: row counts (u16, or u32 in PSB), then the packed rows. */
|
|
1295
|
-
declare function encodeRle(decoded: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
1296
|
-
|
|
1297
|
-
interface PsdHeader {
|
|
1298
|
-
psb: boolean;
|
|
1299
|
-
channels: number;
|
|
1300
|
-
height: number;
|
|
1301
|
-
width: number;
|
|
1302
|
-
depth: number;
|
|
1303
|
-
colorMode: number;
|
|
1304
|
-
}
|
|
1305
|
-
interface PsdRect {
|
|
1306
|
-
top: number;
|
|
1307
|
-
left: number;
|
|
1308
|
-
bottom: number;
|
|
1309
|
-
right: number;
|
|
1310
|
-
}
|
|
1311
|
-
interface PsdChannel {
|
|
1312
|
-
id: number;
|
|
1313
|
-
/** `null` for a zero-length channel. */
|
|
1314
|
-
compression: number | null;
|
|
1315
|
-
/** Encoded bytes, without the compression field. */
|
|
1316
|
-
data: Uint8Array;
|
|
1317
|
-
}
|
|
1318
|
-
interface PsdLayerMask {
|
|
1319
|
-
rect: PsdRect;
|
|
1320
|
-
defaultColor: number;
|
|
1321
|
-
flags: number;
|
|
1322
|
-
userDensity?: number;
|
|
1323
|
-
userFeather?: number;
|
|
1324
|
-
vectorDensity?: number;
|
|
1325
|
-
vectorFeather?: number;
|
|
1326
|
-
/** The real (vector-combined) user mask, when present. */
|
|
1327
|
-
real?: {
|
|
1328
|
-
flags: number;
|
|
1329
|
-
background: number;
|
|
1330
|
-
rect: PsdRect;
|
|
1331
|
-
};
|
|
1332
|
-
}
|
|
1333
|
-
interface PsdTaggedBlock {
|
|
1334
|
-
key: string;
|
|
1335
|
-
data: Uint8Array;
|
|
1336
|
-
}
|
|
1337
|
-
interface PsdLayerRecord {
|
|
1338
|
-
rect: PsdRect;
|
|
1339
|
-
channels: PsdChannel[];
|
|
1340
|
-
blendKey: string;
|
|
1341
|
-
opacity: number;
|
|
1342
|
-
clipping: number;
|
|
1343
|
-
flags: number;
|
|
1344
|
-
mask?: PsdLayerMask;
|
|
1345
|
-
/** The legacy (Pascal) name; `layerName` prefers `luni`. */
|
|
1346
|
-
legacyName: string;
|
|
1347
|
-
blocks: PsdTaggedBlock[];
|
|
1348
|
-
}
|
|
1349
|
-
interface PsdResource {
|
|
1350
|
-
id: number;
|
|
1351
|
-
name: string;
|
|
1352
|
-
data: Uint8Array;
|
|
1353
|
-
}
|
|
1354
|
-
interface PsdFile {
|
|
1355
|
-
header: PsdHeader;
|
|
1356
|
-
colorModeData: Uint8Array;
|
|
1357
|
-
resources: PsdResource[];
|
|
1358
|
-
/** Bottom-most first, as stored. */
|
|
1359
|
-
layers: PsdLayerRecord[];
|
|
1360
|
-
/** The layer count was negative: the merged image's first extra channel is its alpha. */
|
|
1361
|
-
mergedAlpha: boolean;
|
|
1362
|
-
globalBlocks: PsdTaggedBlock[];
|
|
1363
|
-
imageCompression: number;
|
|
1364
|
-
imageData: Uint8Array;
|
|
1365
|
-
}
|
|
1366
|
-
/** Parses a PSD or PSB. Throws `PsdError` with what was wrong. */
|
|
1367
|
-
declare function readPsd(bytes: Uint8Array): PsdFile;
|
|
1368
|
-
declare function layerName(rec: PsdLayerRecord): string;
|
|
1369
|
-
interface PsdTreeNode {
|
|
1370
|
-
/** Index into `PsdFile.layers` (the folder record for a group). */
|
|
1371
|
-
index: number;
|
|
1372
|
-
children?: PsdTreeNode[];
|
|
1373
|
-
}
|
|
1374
|
-
/** The layer tree, bottom-most first (the stored order, as in our model), from the `lsct` dividers. */
|
|
1375
|
-
declare function layerTree(file: PsdFile): PsdTreeNode[];
|
|
1376
|
-
/** One layer channel decoded to `depth`-bit planar bytes, or `undefined` if the layer has none. */
|
|
1377
|
-
declare function decodeLayerChannel(file: PsdFile, rec: PsdLayerRecord, id: number): Uint8Array | undefined;
|
|
1378
|
-
/** The merged image's channels decoded, planar. */
|
|
1379
|
-
declare function decodeMergedImage(file: PsdFile): Uint8Array;
|
|
1380
|
-
/** Serializes a file. Channel data must already be encoded; `encodeName` writes legacy (Pascal) names. */
|
|
1381
|
-
declare function writePsd(file: PsdFile, encodeName: (s: string) => Uint8Array): Uint8Array;
|
|
1382
|
-
|
|
1383
|
-
/** PSD blend keys → our blend modes (`diss` is the one we lack). */
|
|
1384
|
-
declare const PSD_BLEND_KEYS: Record<string, LayerBlendMode>;
|
|
1385
|
-
/** What happened to one PSD layer on import. */
|
|
1386
|
-
interface PsdLayerSummary {
|
|
1387
|
-
name: string;
|
|
1388
|
-
/** Our layer type, or `null` when the layer was dropped. */
|
|
1389
|
-
type: 'pixel' | 'adjustment' | 'group' | null;
|
|
1390
|
-
/** `mapped`: held exactly; `approximated`: imported with losses; `dropped`: left out. */
|
|
1391
|
-
status: 'mapped' | 'approximated' | 'dropped';
|
|
1392
|
-
/** What Photoshop calls it (`pixel`, `type`, `smart-object`, `fill`, `shape`, `Levels` …). */
|
|
1393
|
-
psdKind: string;
|
|
1394
|
-
/** Why it is not `mapped`. */
|
|
1395
|
-
notes: string[];
|
|
1396
|
-
/** Our layer id (when imported). */
|
|
1397
|
-
id?: string;
|
|
1398
|
-
depth: number;
|
|
1399
|
-
}
|
|
1400
|
-
interface PsdImportResult {
|
|
1401
|
-
width: number;
|
|
1402
|
-
height: number;
|
|
1403
|
-
/** Bottom to top, as in our model. */
|
|
1404
|
-
layers: ImageLayer[];
|
|
1405
|
-
/** One sentence per problem, naming the affected layers. */
|
|
1406
|
-
warnings: string[];
|
|
1407
|
-
/** Every PSD layer, bottom first, a group before its children. */
|
|
1408
|
-
summary: PsdLayerSummary[];
|
|
1409
|
-
/** Pixels per inch, when the file says. */
|
|
1410
|
-
resolution?: number;
|
|
1411
|
-
/** The patterns embedded in the file (`Patt` / `Pat2` / `Pat3`), which pattern effects use. */
|
|
1412
|
-
patterns: EffectPattern[];
|
|
1413
|
-
/** The global light (image resources 1037 and 1049), when the file has one. */
|
|
1414
|
-
globalLight?: GlobalLight;
|
|
1415
|
-
info: {
|
|
1416
|
-
psb: boolean;
|
|
1417
|
-
depth: number;
|
|
1418
|
-
colorMode: string;
|
|
1419
|
-
channels: number;
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
interface PsdImportOptions {
|
|
1423
|
-
/** Makes layer ids (defaults to `psd-<n>`). */
|
|
1424
|
-
newId?: (hint: string) => string;
|
|
1425
|
-
/** Skip decoding pixels (inspection only). */
|
|
1426
|
-
skipPixels?: boolean;
|
|
1427
|
-
}
|
|
1428
|
-
/** Maps a parsed PSD to our layers. */
|
|
1429
|
-
declare function psdToLayers(file: PsdFile, options?: PsdImportOptions): PsdImportResult;
|
|
1430
|
-
/** Parses and maps PSD / PSB bytes. Throws `PsdError` for files that cannot be read at all. */
|
|
1431
|
-
declare function importPsd(bytes: Uint8Array, options?: PsdImportOptions): PsdImportResult;
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1434
|
-
* Free Transform geometry for the image editor, as pure functions both the UI bindings and the
|
|
1435
|
-
* agent tools use: a transform is the frame being transformed (`box`, document pixels), where its
|
|
1436
|
-
* four corners land (`corners`, TL, TR, BR, BL) and an optional warp mesh over the box. Scale,
|
|
1437
|
-
* rotate, skew and flips keep the corners a parallelogram (an affine map); Distort and Perspective
|
|
1438
|
-
* move them freely (a projective map); Warp bends the box through a Bézier mesh before the corner
|
|
1439
|
-
* map.
|
|
1440
|
-
*
|
|
1441
|
-
* The maths (homographies, meshes, presets) is shared with the vector editor in `src/geom`.
|
|
1442
|
-
*/
|
|
1443
|
-
|
|
1444
|
-
/** Free Transform modes (Edit › Transform). Scale, rotate and skew stay affine. */
|
|
1445
|
-
type FreeTransformMode = 'scale' | 'rotate' | 'skew' | 'distort' | 'perspective' | 'warp';
|
|
1446
|
-
declare const FREE_TRANSFORM_MODES: readonly FreeTransformMode[];
|
|
1447
|
-
/** The nine reference-point positions of the options bar's locator, over the transformed box. */
|
|
1448
|
-
type TransformAnchor = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
|
|
1449
|
-
declare const TRANSFORM_ANCHORS: readonly TransformAnchor[];
|
|
1450
|
-
declare function isTransformAnchor(value: unknown): value is TransformAnchor;
|
|
1451
|
-
/** A transform in progress: the frame, where its corners go and an optional warp over the frame. */
|
|
1452
|
-
interface FreeTransformGeometry {
|
|
1453
|
-
/** The frame being transformed, in document pixels (the content bounds when it began). */
|
|
1454
|
-
box: CropBox;
|
|
1455
|
-
/** Where the frame's corners land: top-left, top-right, bottom-right, bottom-left (document pixels). */
|
|
1456
|
-
corners: Quad;
|
|
1457
|
-
/**
|
|
1458
|
-
* A warp applied in the frame's own space before the corner map: its control points are in
|
|
1459
|
-
* document pixels of the untransformed frame (`identityWarpMesh(box)` is no warp).
|
|
1460
|
-
*/
|
|
1461
|
-
warp?: WarpMesh | null;
|
|
1462
|
-
}
|
|
1463
|
-
/** The untransformed geometry of a box. */
|
|
1464
|
-
declare function identityTransform(box: CropBox): FreeTransformGeometry;
|
|
1465
|
-
/** Where `box`'s corners go under the affine `m`. */
|
|
1466
|
-
declare function cornersFromMatrix(box: CropBox, m: AffineMatrix): Quad;
|
|
1467
|
-
/** The affine matrix taking `box` onto `corners` when they form a parallelogram, else `null`. */
|
|
1468
|
-
declare function matrixFromCorners(box: CropBox, corners: Quad, eps?: number): AffineMatrix | null;
|
|
1469
|
-
/** The projective map of the corner move (box → corners), or `null` when the corners are degenerate. */
|
|
1470
|
-
declare function transformHomography(geometry: FreeTransformGeometry): Homography | null;
|
|
1471
|
-
/** Whether a warp mesh changes anything (not the identity over the box). */
|
|
1472
|
-
declare function hasWarp(geometry: FreeTransformGeometry): boolean;
|
|
1473
|
-
/** Whether the geometry changes nothing. */
|
|
1474
|
-
declare function isIdentityTransform(geometry: FreeTransformGeometry): boolean;
|
|
1475
|
-
/**
|
|
1476
|
-
* The forward map of the whole transform (document pixels of the source → document pixels of the
|
|
1477
|
-
* result): the warp over the box, then the corner map. `null` where it is undefined.
|
|
1478
|
-
*/
|
|
1479
|
-
declare function transformMap(geometry: FreeTransformGeometry): ((p: Vec2) => Vec2 | null) | null;
|
|
1480
|
-
/** A point of the transformed box at box fractions (`fx`, `fy`), warp included. */
|
|
1481
|
-
declare function transformedPoint(geometry: FreeTransformGeometry, fx: number, fy: number): Vec2 | null;
|
|
1482
|
-
/** Where an anchor of the box is after the corner map (the warp ignored). */
|
|
1483
|
-
declare function anchorPoint(geometry: FreeTransformGeometry, anchor: TransformAnchor): Vec2;
|
|
1484
|
-
/** Bounds of the transformed result's outline (document pixels, not rounded). */
|
|
1485
|
-
declare function transformedBox(geometry: FreeTransformGeometry): CropBox | null;
|
|
1486
|
-
/** Free Transform as numbers, as Photoshop's options bar shows it. */
|
|
1487
|
-
interface TransformParams {
|
|
1488
|
-
/** Width in percent of the frame (default 100; negative flips). */
|
|
1489
|
-
scaleX?: number;
|
|
1490
|
-
/** Height in percent of the frame (default 100; negative flips). */
|
|
1491
|
-
scaleY?: number;
|
|
1492
|
-
/** Rotation in degrees, clockwise (default 0). */
|
|
1493
|
-
rotate?: number;
|
|
1494
|
-
/** Horizontal skew in degrees: vertical edges lean right for positive angles (default 0). */
|
|
1495
|
-
skewX?: number;
|
|
1496
|
-
/** Vertical skew in degrees: horizontal edges lean down for positive angles (default 0). */
|
|
1497
|
-
skewY?: number;
|
|
1498
|
-
/** Move after scaling and rotating, in document pixels (default 0). */
|
|
1499
|
-
dx?: number;
|
|
1500
|
-
dy?: number;
|
|
1501
|
-
/** The fixed point of scale, skew and rotation: an anchor of the frame or a document point (default the centre). */
|
|
1502
|
-
reference?: TransformAnchor | Vec2;
|
|
1503
|
-
}
|
|
1504
|
-
/** The reference point of params over a box (default its centre). */
|
|
1505
|
-
declare function referencePoint(box: CropBox, reference: TransformParams['reference']): Vec2;
|
|
1506
|
-
/**
|
|
1507
|
-
* The affine matrix of `params` over `box`: about the reference point, skew, then scale, then
|
|
1508
|
-
* rotate; then the move.
|
|
1509
|
-
*/
|
|
1510
|
-
declare function matrixFromParams(box: CropBox, params: TransformParams): AffineMatrix;
|
|
1511
|
-
/** What the options bar shows for a transform. */
|
|
1512
|
-
interface TransformReadout {
|
|
1513
|
-
/** False for Distort, Perspective and Warp: only `bounds` and `corners` then mean anything. */
|
|
1514
|
-
affine: boolean;
|
|
1515
|
-
/** Width and height in percent of the frame. */
|
|
1516
|
-
scaleX: number;
|
|
1517
|
-
scaleY: number;
|
|
1518
|
-
/** Rotation in degrees, clockwise, in (−180, 180]. */
|
|
1519
|
-
rotate: number;
|
|
1520
|
-
/** Horizontal skew in degrees (vertical skew is folded into rotation and scale). */
|
|
1521
|
-
skewX: number;
|
|
1522
|
-
/** Where the reference point is now (document pixels). */
|
|
1523
|
-
x: number;
|
|
1524
|
-
y: number;
|
|
1525
|
-
/** Bounds of the transformed outline. */
|
|
1526
|
-
bounds: CropBox | null;
|
|
1527
|
-
corners: Quad;
|
|
1528
|
-
}
|
|
1529
|
-
/**
|
|
1530
|
-
* Decomposes a transform for the options bar: the linear part as rotate · scale · skew (QR) with
|
|
1531
|
-
* the given reference point. Non-affine geometry reports its bounds and corners only.
|
|
1532
|
-
*/
|
|
1533
|
-
declare function describeTransform(geometry: FreeTransformGeometry, reference?: TransformParams['reference']): TransformReadout;
|
|
1534
|
-
/**
|
|
1535
|
-
* Corners for a transform given as numbers relative to the current corners: `params` are applied
|
|
1536
|
-
* after the current affine part (when the corners are a parallelogram) about the reference point
|
|
1537
|
-
* of the current geometry, so typing "rotate 15" rotates the box as it is now.
|
|
1538
|
-
*/
|
|
1539
|
-
declare function applyParams(geometry: FreeTransformGeometry, params: TransformParams): Quad;
|
|
1540
|
-
/** Flip of the corners about the box's centre line (horizontal: left ↔ right). */
|
|
1541
|
-
declare function flipCorners(geometry: FreeTransformGeometry, axis: 'horizontal' | 'vertical'): Quad;
|
|
1542
|
-
/** Inverse of `matrixFromCorners` (box space → document) for mapping a document point back into the box. */
|
|
1543
|
-
declare function boxPointOf(geometry: FreeTransformGeometry, p: Vec2): Vec2 | null;
|
|
1544
|
-
/** A warp mesh from a preset over the box (null when it changes nothing). */
|
|
1545
|
-
declare function presetWarp(box: CropBox, preset: WarpPreset): WarpMesh | null;
|
|
1546
|
-
/** Validates a warp mesh for a box: well formed, finite, the right number of points. */
|
|
1547
|
-
declare function isValidWarp(mesh: unknown): mesh is WarpMesh;
|
|
1548
|
-
/** The geometry's affine map when it is one (no warp, a parallelogram), as a homography; else the projective map. */
|
|
1549
|
-
declare function geometryHomography(geometry: FreeTransformGeometry): Homography | null;
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* Free Transform sessions: what a transform moves (a layer's pixels with its linked mask, a lone
|
|
1553
|
-
* unlinked mask, the selected pixels as a floating piece, a copy of them on a new layer, or just
|
|
1554
|
-
* the selection outline), a live preview while the geometry changes, and one undo step when it is
|
|
1555
|
-
* committed with full-quality resampling.
|
|
1556
|
-
*/
|
|
1557
|
-
|
|
1558
|
-
/**
|
|
1559
|
-
* What a Free Transform moves:
|
|
1560
|
-
* - `layer`: the layer's pixels with its linked mask (or, with `channel: 'mask'` on an unlinked
|
|
1561
|
-
* mask, the mask alone);
|
|
1562
|
-
* - `selection`: the selected pixels (and the same part of a linked mask), lifted and committed
|
|
1563
|
-
* back into the layer; the selection outline moves with them;
|
|
1564
|
-
* - `selection-copy`: Layer via Copy, then the copy is transformed on a new layer above;
|
|
1565
|
-
* - `selection-outline`: Transform Selection, only the outline;
|
|
1566
|
-
* - `auto` (default): `selection` when something is selected, else `layer`.
|
|
1567
|
-
*/
|
|
1568
|
-
type FreeTransformContent = 'auto' | 'layer' | 'selection' | 'selection-copy' | 'selection-outline';
|
|
1569
|
-
declare const FREE_TRANSFORM_CONTENTS: readonly FreeTransformContent[];
|
|
1570
|
-
interface FreeTransformInit {
|
|
1571
|
-
/** The layer (default the active one); not needed for `selection-outline`. */
|
|
1572
|
-
layerId?: string;
|
|
1573
|
-
content?: FreeTransformContent;
|
|
1574
|
-
/**
|
|
1575
|
-
* `pixels` (default) moves the pixels with a linked mask; `mask` moves an unlinked mask alone (a
|
|
1576
|
-
* linked one moves with its pixels). Defaults to the active target on the active layer.
|
|
1577
|
-
*/
|
|
1578
|
-
channel?: LayerTarget;
|
|
1579
|
-
/** Resampling of the committed result (default bicubic). */
|
|
1580
|
-
interpolation?: Interpolation;
|
|
1581
|
-
}
|
|
1582
|
-
/** How a live preview is drawn (the UI knows these, the controller doesn't). */
|
|
1583
|
-
interface FreeTransformPreview {
|
|
1584
|
-
/** Screen pixels per document pixel: below 1 the preview samples a reduced copy in blocks. */
|
|
1585
|
-
scale?: number;
|
|
1586
|
-
/** Only this part of the document (the visible area) is resampled. */
|
|
1587
|
-
clip?: CropBox;
|
|
1588
|
-
}
|
|
1589
|
-
/** What a committed transform changed. */
|
|
1590
|
-
interface FreeTransformResult {
|
|
1591
|
-
/** The layer that holds the result (the new layer for `selection-copy`; `null` for `selection-outline`). */
|
|
1592
|
-
layerId: string | null;
|
|
1593
|
-
content: Exclude<FreeTransformContent, 'auto'>;
|
|
1594
|
-
/** What moved. */
|
|
1595
|
-
moved: Array<'pixels' | 'mask' | 'selection'>;
|
|
1596
|
-
/** The frame the transform started from (document pixels). */
|
|
1597
|
-
box: CropBox;
|
|
1598
|
-
/** Where the frame's corners went. */
|
|
1599
|
-
corners: FreeTransformGeometry['corners'];
|
|
1600
|
-
/** Document bounds of the moved content after the transform (pixels, or the mask or the outline). */
|
|
1601
|
-
bounds: CropBox | null;
|
|
1602
|
-
/** False when the geometry was the identity and nothing was recorded. */
|
|
1603
|
-
changed: boolean;
|
|
1604
|
-
}
|
|
1605
|
-
/** @internal What the session needs from the controller. */
|
|
1606
|
-
interface FreeTransformHost {
|
|
1607
|
-
layers(): ImageLayer[];
|
|
1608
|
-
activeLayerId(): string | null;
|
|
1609
|
-
activeTarget(): LayerTarget;
|
|
1610
|
-
selection(): SelectionMask | null;
|
|
1611
|
-
canvas(): {
|
|
1612
|
-
width: number;
|
|
1613
|
-
height: number;
|
|
1614
|
-
};
|
|
1615
|
-
/** The pixels a pixel layer or smart object composites (the decoded source for the Background). */
|
|
1616
|
-
pixelsOf(layer: PixelLayer | SmartObjectLayer): TiledSurface;
|
|
1617
|
-
/** Opaque pre-transform snapshot. */
|
|
1618
|
-
capture(): unknown;
|
|
1619
|
-
/** Shows a live state (no history). */
|
|
1620
|
-
show(layers: ImageLayer[], selection: SelectionMask | null, activeLayerId: string | null): void;
|
|
1621
|
-
/** Records `before` as the undo step of the state now shown. */
|
|
1622
|
-
record(before: unknown): void;
|
|
1623
|
-
/** Puts `before` back (no history). */
|
|
1624
|
-
restore(before: unknown): void;
|
|
1625
|
-
}
|
|
1626
|
-
/** Preview block size for a screen scale: 1 at 100 % and above, then powers of two up to 8. */
|
|
1627
|
-
declare function previewStep(scale: number | undefined): number;
|
|
1628
|
-
/**
|
|
1629
|
-
* A Free Transform in progress (see `ImageEditorController.beginFreeTransform`). Change the
|
|
1630
|
-
* geometry with `update` (each change shows a live preview without history), then `commit()`
|
|
1631
|
-
* (one undo step, resampled at full quality) or `cancel()` (everything back as it was).
|
|
1632
|
-
*/
|
|
1633
|
-
declare class FreeTransformSession {
|
|
1634
|
-
private readonly host;
|
|
1635
|
-
readonly content: Exclude<FreeTransformContent, 'auto'>;
|
|
1636
|
-
/** The layer being transformed (`null` for `selection-outline`). */
|
|
1637
|
-
readonly layerId: string | null;
|
|
1638
|
-
/** The new layer of a `selection-copy`. */
|
|
1639
|
-
readonly copyId: string | null;
|
|
1640
|
-
/** The frame (document pixels). */
|
|
1641
|
-
readonly box: CropBox;
|
|
1642
|
-
/** What moves. */
|
|
1643
|
-
readonly moves: ReadonlyArray<'pixels' | 'mask' | 'selection'>;
|
|
1644
|
-
/**
|
|
1645
|
-
* The geometry the transform starts from: the identity over `box`, or for a smart object its
|
|
1646
|
-
* placement (`box` is then the contents' rectangle in contents pixels, and the transform edits
|
|
1647
|
-
* the placement without resampling anything twice).
|
|
1648
|
-
*/
|
|
1649
|
-
readonly startGeometry: FreeTransformGeometry;
|
|
1650
|
-
/** True when the layer is a smart object (the transform sets its placement). */
|
|
1651
|
-
readonly smartObject: boolean;
|
|
1652
|
-
private geometryValue;
|
|
1653
|
-
private readonly smart;
|
|
1654
|
-
private readonly smartReduced;
|
|
1655
|
-
private readonly startInterp;
|
|
1656
|
-
private smartMasksMoved;
|
|
1657
|
-
private interp;
|
|
1658
|
-
private readonly parts;
|
|
1659
|
-
private readonly before;
|
|
1660
|
-
private readonly startLayers;
|
|
1661
|
-
private readonly startSelection;
|
|
1662
|
-
private readonly startActive;
|
|
1663
|
-
/** The stack this session last showed: anything else means the document changed under it. */
|
|
1664
|
-
private shown;
|
|
1665
|
-
private closed;
|
|
1666
|
-
constructor(host: FreeTransformHost, init?: FreeTransformInit);
|
|
1667
|
-
/** The current geometry. */
|
|
1668
|
-
get geometry(): FreeTransformGeometry;
|
|
1669
|
-
get interpolation(): Interpolation;
|
|
1670
|
-
get isOpen(): boolean;
|
|
1671
|
-
private check;
|
|
1672
|
-
/**
|
|
1673
|
-
* Changes the geometry (`corners`, `warp`) or the interpolation and, unless `preview` is `false`,
|
|
1674
|
-
* shows the result live (no history). Returns the geometry.
|
|
1675
|
-
*/
|
|
1676
|
-
update(changes: {
|
|
1677
|
-
corners?: FreeTransformGeometry['corners'];
|
|
1678
|
-
warp?: FreeTransformGeometry['warp'];
|
|
1679
|
-
interpolation?: Interpolation;
|
|
1680
|
-
}, preview?: FreeTransformPreview | false): FreeTransformGeometry;
|
|
1681
|
-
/** Resamples every part for the current geometry and shows it (or returns it, for commit). */
|
|
1682
|
-
private resample;
|
|
1683
|
-
/** A smart object re-rendered from its contents for the current geometry (previews leave the smart filters out). */
|
|
1684
|
-
private resampleSmart;
|
|
1685
|
-
/** Whether the geometry (or the interpolation of a smart object) differs from where it started. */
|
|
1686
|
-
private isChanged;
|
|
1687
|
-
private render;
|
|
1688
|
-
/** Finishes the transform with full-quality resampling, as one undo step. */
|
|
1689
|
-
commit(): FreeTransformResult;
|
|
1690
|
-
/** Abandons the transform and puts everything back (no history). */
|
|
1691
|
-
cancel(): void;
|
|
1692
|
-
private result;
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
/** What `getSmartObject` reports. */
|
|
1696
|
-
interface SmartObjectInfo {
|
|
1697
|
-
layerId: string;
|
|
1698
|
-
contents: {
|
|
1699
|
-
/** Shared by linked instances. */
|
|
1700
|
-
id: string;
|
|
1701
|
-
name: string;
|
|
1702
|
-
kind: 'raster' | 'document';
|
|
1703
|
-
/** Pixel size of the contents. */
|
|
1704
|
-
width: number;
|
|
1705
|
-
height: number;
|
|
1706
|
-
/** False for a file that could not be decoded here (the layer shows its stored pixels). */
|
|
1707
|
-
decoded: boolean;
|
|
1708
|
-
/** The type of the file the contents came from (`psb`, `png`, `jpg`, …), or `null`. */
|
|
1709
|
-
fileType: string | null;
|
|
1710
|
-
/** The external file of linked contents, or `null` for embedded ones. */
|
|
1711
|
-
linkedPath: string | null;
|
|
1712
|
-
/** Every smart object placed from these contents (this one included), bottom first. */
|
|
1713
|
-
instances: string[];
|
|
1714
|
-
/** Layers in a nested document (0 for raster contents). */
|
|
1715
|
-
layerCount: number;
|
|
1716
|
-
};
|
|
1717
|
-
placement: {
|
|
1718
|
-
/** Where the contents' corners land: top-left, top-right, bottom-right, bottom-left (document pixels). */
|
|
1719
|
-
corners: Quad;
|
|
1720
|
-
/** The warp mesh in contents pixels, or `null`. */
|
|
1721
|
-
warp: WarpMesh | null;
|
|
1722
|
-
interpolation: Interpolation;
|
|
1723
|
-
/** False for distort, perspective and warp (then only corners and bounds describe it). */
|
|
1724
|
-
affine: boolean;
|
|
1725
|
-
/** Percent of the contents' own size. */
|
|
1726
|
-
scaleX: number;
|
|
1727
|
-
scaleY: number;
|
|
1728
|
-
rotate: number;
|
|
1729
|
-
skewX: number;
|
|
1730
|
-
/** Where the contents' centre is (document pixels). */
|
|
1731
|
-
center: {
|
|
1732
|
-
x: number;
|
|
1733
|
-
y: number;
|
|
1734
|
-
};
|
|
1735
|
-
/** Bounds of the placed outline. */
|
|
1736
|
-
bounds: CropBox | null;
|
|
1737
|
-
};
|
|
1738
|
-
smartFilters: {
|
|
1739
|
-
enabled: boolean;
|
|
1740
|
-
/** Bottom (applied first) to top. Photoshop filters we keep but do not draw have kind `psd`. */
|
|
1741
|
-
filters: Array<Record<string, unknown>>;
|
|
1742
|
-
mask: {
|
|
1743
|
-
enabled: boolean;
|
|
1744
|
-
linked: boolean;
|
|
1745
|
-
density: number;
|
|
1746
|
-
feather: number;
|
|
1747
|
-
bounds: CropBox | null;
|
|
1748
|
-
defaultValue: number;
|
|
1749
|
-
} | null;
|
|
1750
|
-
};
|
|
1751
|
-
/** Document bounds of the rendered pixels. */
|
|
1752
|
-
bounds: CropBox | null;
|
|
1753
|
-
}
|
|
1754
|
-
/** Latest serialized schema version (`3`: layers). Documents with the old shape still write 1 or 2. */
|
|
1755
|
-
declare const IMAGE_EDITOR_SCHEMA_VERSION: 3;
|
|
1756
|
-
/** Changes to an adjustment layer; `params` is merged into the current parameters. */
|
|
1757
|
-
interface AdjustmentLayerUpdate<K extends AdjustmentKind = AdjustmentKind> {
|
|
1758
|
-
params?: Partial<AdjustmentParamsMap[K]>;
|
|
1759
|
-
enabled?: boolean;
|
|
1760
|
-
opacity?: number;
|
|
1761
|
-
blend?: BlendMode;
|
|
1762
|
-
name?: string;
|
|
1763
|
-
/** A layer mask, or `null` to remove it. */
|
|
1764
|
-
mask?: AdjustmentLayerMask | null;
|
|
1765
|
-
}
|
|
1766
|
-
/** Options shared by the selection commands. */
|
|
1767
|
-
interface SelectionCommandOptions {
|
|
1768
|
-
/** How the result combines with the current selection (default `replace`). */
|
|
1769
|
-
mode?: SelectionMode;
|
|
1770
|
-
/** Feather the new shape by this many pixels before combining (default 0). */
|
|
1771
|
-
feather?: number;
|
|
1772
|
-
}
|
|
1773
|
-
/** Where an AI result goes (see `applyInpaintedImage`, `applyBackgroundRemovedImage`). */
|
|
1774
|
-
interface AIResultOptions {
|
|
1775
|
-
/** `new-layer`: a new layer (inpainting) or a mask (background removal); `replace`: the Background's pixels. Default: by `isMultiLayer`. */
|
|
1776
|
-
target?: 'new-layer' | 'replace';
|
|
1777
|
-
}
|
|
1778
|
-
/** Where the selection tools read colours from. */
|
|
1779
|
-
interface SampleOptions {
|
|
1780
|
-
/**
|
|
1781
|
-
* `composite` (default): the image, as before (with several layers: the composite of the pixel
|
|
1782
|
-
* layers, or with `sampleMerged` of every layer); `active-layer`: only the active pixel layer.
|
|
1783
|
-
*/
|
|
1784
|
-
sample?: 'composite' | 'active-layer';
|
|
1785
|
-
/** Sample the adjusted image (base adjustments and layers) instead of the source pixels. */
|
|
1786
|
-
sampleMerged?: boolean;
|
|
1787
|
-
/** Pixels to use instead of reading the source image (natural size, RGBA). */
|
|
1788
|
-
pixels?: PixelBuffer;
|
|
1789
|
-
}
|
|
1790
|
-
/** A new adjustment layer: its kind plus optional initial values and position. */
|
|
1791
|
-
interface AdjustmentLayerInit<K extends AdjustmentKind = AdjustmentKind> extends AdjustmentLayerUpdate<K> {
|
|
1792
|
-
kind: K;
|
|
1793
|
-
id?: string;
|
|
1794
|
-
/** Put the new layer directly above this layer (in its group). */
|
|
1795
|
-
aboveId?: string;
|
|
1796
|
-
/** Put the new layer at the top of this group. */
|
|
1797
|
-
parentId?: string;
|
|
1798
|
-
}
|
|
1799
|
-
/** A new pixel layer: empty, a solid colour over the canvas, or given pixels, plus its properties and position. */
|
|
1800
|
-
interface PixelLayerInit extends LayerPlacement {
|
|
1801
|
-
id?: string;
|
|
1802
|
-
name?: string;
|
|
1803
|
-
/** Fill the canvas with this colour (`#rgb`, `#rrggbb`, `#rrggbbaa` or `[r, g, b, a?]` 0..255). */
|
|
1804
|
-
color?: string | number[];
|
|
1805
|
-
/** RGBA pixels placed at `x`, `y` (document pixels). */
|
|
1806
|
-
pixels?: PixelBuffer;
|
|
1807
|
-
x?: number;
|
|
1808
|
-
y?: number;
|
|
1809
|
-
visible?: boolean;
|
|
1810
|
-
/** 0..1 (default 1). */
|
|
1811
|
-
opacity?: number;
|
|
1812
|
-
fillOpacity?: number;
|
|
1813
|
-
blend?: BlendMode;
|
|
1814
|
-
}
|
|
1815
|
-
/** The paint tools' options (view state). */
|
|
1816
|
-
interface PaintOptions {
|
|
1817
|
-
brush: BrushSettings;
|
|
1818
|
-
/** `#rrggbb`: what the brush and Fill paint. */
|
|
1819
|
-
foreground: string;
|
|
1820
|
-
/** `#rrggbb`: what the eraser paints on transparency-locked layers and masks. */
|
|
1821
|
-
background: string;
|
|
1822
|
-
/** Mixer Brush options (wet, load, mix, load / clean each stroke, RGB or pigment mixing). */
|
|
1823
|
-
mixer: MixerSettings;
|
|
1824
|
-
/** What the Mixer Brush carries now: its reservoir, how much is left and the picked-up colour. */
|
|
1825
|
-
mixerLoad: MixerLoad;
|
|
1826
|
-
}
|
|
1827
|
-
/** Paint tools a stroke can use. */
|
|
1828
|
-
type StrokeTool = 'brush' | 'eraser' | 'mixer';
|
|
1829
|
-
/** A stroke: tool, target (default the active layer and target) and brush / colour overrides. */
|
|
1830
|
-
interface StrokeInit {
|
|
1831
|
-
tool?: StrokeTool;
|
|
1832
|
-
layerId?: string;
|
|
1833
|
-
channel?: LayerTarget;
|
|
1834
|
-
/** Overrides of the paint options' brush. */
|
|
1835
|
-
brush?: Partial<BrushSettings>;
|
|
1836
|
-
/**
|
|
1837
|
-
* Paint colour (default the foreground). Masks take its grey value. For the mixer, the colour
|
|
1838
|
-
* the reservoir is loaded with: given, it loads the brush whatever `loadEachStroke` says.
|
|
1839
|
-
*/
|
|
1840
|
-
color?: string | number[];
|
|
1841
|
-
/** Overrides of the paint options' Mixer Brush settings (tool `mixer`). */
|
|
1842
|
-
mixer?: Partial<MixerSettings>;
|
|
1843
|
-
/** Eraser colour on locked transparency / masks (default the background). */
|
|
1844
|
-
background?: string | number[];
|
|
1845
|
-
/** Kept with the stroke for replays (v1 brushes have no jitter). */
|
|
1846
|
-
seed?: number;
|
|
1847
|
-
}
|
|
1848
|
-
interface FillOptions {
|
|
1849
|
-
layerId?: string;
|
|
1850
|
-
channel?: LayerTarget;
|
|
1851
|
-
/** Default the foreground colour. */
|
|
1852
|
-
color?: string | number[];
|
|
1853
|
-
/** 0..1 (default 1). */
|
|
1854
|
-
opacity?: number;
|
|
1855
|
-
blend?: BlendMode;
|
|
1856
|
-
/** Limit to the selection when there is one (default true). */
|
|
1857
|
-
useSelection?: boolean;
|
|
1858
|
-
}
|
|
1859
|
-
/** What a stroke, fill or clear changed. */
|
|
1860
|
-
interface PaintStrokeResult {
|
|
1861
|
-
layerId: string;
|
|
1862
|
-
channel: LayerTarget;
|
|
1863
|
-
/** Document rectangle that changed (null when nothing did). */
|
|
1864
|
-
bounds: CropBox | null;
|
|
1865
|
-
dabs: number;
|
|
1866
|
-
/** The Mixer Brush's load after the stroke (tool `mixer` only). */
|
|
1867
|
-
mixerLoad?: MixerLoad;
|
|
1868
|
-
}
|
|
1869
|
-
/** An opaque pre-stroke history snapshot. */
|
|
1870
|
-
type HistoryEntryHandle = {
|
|
1871
|
-
readonly __historyEntry: unique symbol;
|
|
1872
|
-
};
|
|
1873
|
-
/** How a Mixer Brush stroke starts (see `PaintStrokeSession`). */
|
|
1874
|
-
interface MixerStrokeInit {
|
|
1875
|
-
/** Makes the stroke over the session's live pixels. */
|
|
1876
|
-
create(pixels: MixerTarget): MixerStroke;
|
|
1877
|
-
/** Stores the brush load when the stroke ends and returns it (after any clean). */
|
|
1878
|
-
end(load: MixerLoad): MixerLoad;
|
|
1879
|
-
}
|
|
1880
|
-
/**
|
|
1881
|
-
* A stroke in progress (see `beginStroke`): `push` input points as they arrive, then `end` (one
|
|
1882
|
-
* undo step) or `cancel`. Brush and eraser strokes build up a coverage map composited over the
|
|
1883
|
-
* pre-stroke pixels; Mixer Brush strokes paint dab by dab into the live pixels, so each dab picks
|
|
1884
|
-
* up what the dabs before it laid down.
|
|
1885
|
-
*/
|
|
1886
|
-
declare class PaintStrokeSession {
|
|
1887
|
-
private readonly controller;
|
|
1888
|
-
readonly target: {
|
|
1889
|
-
id: string;
|
|
1890
|
-
channel: LayerTarget;
|
|
1891
|
-
surface: TiledSurface;
|
|
1892
|
-
};
|
|
1893
|
-
private readonly apply;
|
|
1894
|
-
private readonly before;
|
|
1895
|
-
private readonly base;
|
|
1896
|
-
private readonly live;
|
|
1897
|
-
private readonly touched;
|
|
1898
|
-
private readonly stroke;
|
|
1899
|
-
private readonly mixer;
|
|
1900
|
-
private readonly mixerInit;
|
|
1901
|
-
/** Mixer tiles written since the last update: they get new tile objects so the compositor sees them change. */
|
|
1902
|
-
private readonly fresh;
|
|
1903
|
-
private last;
|
|
1904
|
-
private closed;
|
|
1905
|
-
constructor(controller: ImageEditorController, target: {
|
|
1906
|
-
id: string;
|
|
1907
|
-
channel: LayerTarget;
|
|
1908
|
-
surface: TiledSurface;
|
|
1909
|
-
}, stroke: StrokeCoverage | MixerStrokeInit, apply: StrokeApply);
|
|
1910
|
-
/** The live pixels a mixer stroke reads and writes; base tiles are copied on first write. */
|
|
1911
|
-
private mixerPixels;
|
|
1912
|
-
get layerId(): string;
|
|
1913
|
-
/** Adds input points (document pixels); the stack shows the stroke so far. */
|
|
1914
|
-
push(points: readonly StrokePoint[]): void;
|
|
1915
|
-
private update;
|
|
1916
|
-
/** Finishes the stroke (one undo step) and returns what changed. */
|
|
1917
|
-
end(): PaintStrokeResult;
|
|
1918
|
-
/** Abandons the stroke and restores the layer. */
|
|
1919
|
-
cancel(): void;
|
|
1920
|
-
}
|
|
1921
|
-
/** Where a new annotation goes. */
|
|
1922
|
-
interface AnnotationPlacement {
|
|
1923
|
-
/** Put the annotation layer directly above this layer (default: the top of the stack). */
|
|
1924
|
-
aboveId?: string;
|
|
1925
|
-
}
|
|
1926
|
-
declare const DEFAULT_ADJUSTMENTS: ImageAdjustments;
|
|
1927
|
-
/**
|
|
1928
|
-
* Fills in defaults for stored adjustments. A stored object without `process` was saved before
|
|
1929
|
-
* process versions existed and keeps the legacy rendering.
|
|
1930
|
-
*/
|
|
1931
|
-
declare function normalizeStoredAdjustments(stored: Partial<ImageAdjustments> | undefined | null): ImageAdjustments;
|
|
1932
|
-
/**
|
|
1933
|
-
* Brings a stored editor state of any schema version to a clean state of the same family:
|
|
1934
|
-
* version 1 (and a missing version) has no adjustment layers, version 2 has them, and both stay
|
|
1935
|
-
* in the document-level schema so old states load and render exactly as before. Version 3
|
|
1936
|
-
* (layers) is returned with its document fields cleaned. To lift a v1 / v2 state into layers,
|
|
1937
|
-
* use {@link migrateToLayeredState}.
|
|
1938
|
-
*/
|
|
1939
|
-
declare function migrateSerializedImageEditorState(data: Partial<SerializedImageEditorState> & {
|
|
1940
|
-
version?: number;
|
|
1941
|
-
}): SerializedImageEditorState;
|
|
1942
|
-
/**
|
|
1943
|
-
* Lifts a stored state of any version into the layered schema (v3) for a canvas of
|
|
1944
|
-
* `width × height`: the source becomes the Background layer with the base sliders as its
|
|
1945
|
-
* `develop` filter and the depth mask as its parametric mask, adjustment layers go above it and
|
|
1946
|
-
* annotations on top (see `layersFromLegacy`).
|
|
1947
|
-
*/
|
|
1948
|
-
declare function migrateToLayeredState(data: Partial<SerializedImageEditorState> & {
|
|
1949
|
-
version?: number;
|
|
1950
|
-
}, size: ImageDimensions): SerializedLayeredImageEditorState;
|
|
1951
|
-
declare const DEFAULT_TRANSFORM: ImageTransform;
|
|
1952
|
-
declare const DEFAULT_DEPTH_MASK: DepthMaskOptions;
|
|
1953
|
-
/**
|
|
1954
|
-
* ImageEditorController manages the complete lifecycle, canvas rendering pipeline,
|
|
1955
|
-
* tool interaction states, undo/redo history, serialization, and image export.
|
|
1956
|
-
*/
|
|
1957
|
-
declare class ImageEditorController {
|
|
1958
|
-
private state;
|
|
1959
|
-
private renderer;
|
|
1960
|
-
private imageElement;
|
|
1961
|
-
private listeners;
|
|
1962
|
-
private histogramListeners;
|
|
1963
|
-
private onStateChange?;
|
|
1964
|
-
private undoStack;
|
|
1965
|
-
private redoStack;
|
|
1966
|
-
private maxHistoryDepth;
|
|
1967
|
-
private maxHistoryBytes;
|
|
1968
|
-
private isApplyingHistory;
|
|
1969
|
-
private initialSnapshot;
|
|
1970
|
-
/** Pixels the selection tools sample (host-provided or read back from the source). */
|
|
1971
|
-
private samplePixels;
|
|
1972
|
-
private samplePixelsOverride;
|
|
1973
|
-
/** Decoded source pixels (the Background's surface), by the buffer or element they came from. */
|
|
1974
|
-
private sourceSurfaces;
|
|
1975
|
-
private viewKey;
|
|
1976
|
-
/** For `compositePixels` and mask evaluation (the renderer keeps its own for the viewport). */
|
|
1977
|
-
private compositor;
|
|
1978
|
-
constructor(options?: ImageEditorOptions);
|
|
1979
|
-
/**
|
|
1980
|
-
* Loads a new source image and makes it the baseline that `reset()` returns to.
|
|
1981
|
-
* Does not record history; use `applyInpaintedImage` / `applyBackgroundRemovedImage`
|
|
1982
|
-
* for undoable source replacement.
|
|
1983
|
-
*/
|
|
1984
|
-
loadImage(src: string | HTMLImageElement): Promise<void>;
|
|
1985
|
-
private resolveSource;
|
|
1986
|
-
getImageElement(): CanvasImageSource | null;
|
|
1987
|
-
getState(): ImageEditorState;
|
|
1988
|
-
subscribe(listener: (state: ImageEditorState) => void): () => void;
|
|
1989
|
-
/**
|
|
1990
|
-
* Where layer pixels changed since the last viewport render, when only strokes changed them
|
|
1991
|
-
* (the renderer then recomposites just those rectangles); `'all'` after any other change.
|
|
1992
|
-
*/
|
|
1993
|
-
private pendingDirty;
|
|
1994
|
-
private notify;
|
|
1995
|
-
/** Recomputes the compatibility views (`adjustments`, `depthMask`, `annotations`) when the stack changed. */
|
|
1996
|
-
private syncViews;
|
|
1997
|
-
private stack;
|
|
1998
|
-
private captureHistoryEntry;
|
|
1999
|
-
private restoreHistoryEntry;
|
|
2000
|
-
private recordHistory;
|
|
2001
|
-
/**
|
|
2002
|
-
* Bytes of pixel tiles held only by undo / redo steps (not by the current state). The oldest
|
|
2003
|
-
* undo steps are dropped while it exceeds `maxHistoryBytes`.
|
|
2004
|
-
*/
|
|
2005
|
-
get historyBytes(): number;
|
|
2006
|
-
private trimHistoryBytes;
|
|
2007
|
-
get canUndo(): boolean;
|
|
2008
|
-
get canRedo(): boolean;
|
|
2009
|
-
undo(): boolean;
|
|
2010
|
-
redo(): boolean;
|
|
2011
|
-
reset(): void;
|
|
2012
|
-
setTool(tool: ImageEditorTool): void;
|
|
2013
|
-
setCrop(crop: CropBox | null, addToHistory?: boolean): void;
|
|
2014
|
-
applyCropPreset(ratio: AspectRatio): void;
|
|
2015
|
-
resetCrop(): void;
|
|
2016
|
-
rotate(degrees: number): void;
|
|
2017
|
-
setRotation(degrees: number): void;
|
|
2018
|
-
flipHorizontal(): void;
|
|
2019
|
-
flipVertical(): void;
|
|
2020
|
-
/** The layer stack, bottom to top (immutable objects). */
|
|
2021
|
-
getLayers(): ImageLayer[];
|
|
2022
|
-
getLayer(id: string): ImageLayer | undefined;
|
|
2023
|
-
/** The active layer, or `undefined`. */
|
|
2024
|
-
getActiveLayer(): ImageLayer | undefined;
|
|
2025
|
-
/**
|
|
2026
|
-
* Makes a layer the active one (or none) and chooses whether painting targets its pixels or
|
|
2027
|
-
* its mask. View state: no undo step. Returns false for an unknown id.
|
|
2028
|
-
*/
|
|
2029
|
-
setActiveLayer(id: string | null, target?: LayerTarget): boolean;
|
|
2030
|
-
/**
|
|
2031
|
-
* The pixels of a pixel layer, in document space (`x`, `y` is the top-left of the returned
|
|
2032
|
-
* buffer), or `null` for an unknown or empty layer. Resolves the Background's source pixels.
|
|
2033
|
-
*/
|
|
2034
|
-
getLayerPixels(id: string): (PixelBuffer & {
|
|
2035
|
-
x: number;
|
|
2036
|
-
y: number;
|
|
2037
|
-
}) | null;
|
|
2038
|
-
private boundsCache;
|
|
2039
|
-
/**
|
|
2040
|
-
* Document bounds of a layer's non-transparent pixels (pixel layers; the Background's source
|
|
2041
|
-
* included), or `null` for an empty or non-pixel layer.
|
|
2042
|
-
*/
|
|
2043
|
-
getLayerBounds(id: string): CropBox | null;
|
|
2044
|
-
/**
|
|
2045
|
-
* Composites the layer stack in document space without a canvas (annotation layers need one
|
|
2046
|
-
* and are left out): `rect` (default: the canvas) as RGBA, straight alpha. Crop, rotation and
|
|
2047
|
-
* output opacity are not applied. With `layerIds`, only those layers are composited.
|
|
2048
|
-
*/
|
|
2049
|
-
compositePixels(rect?: CropBox, options?: {
|
|
2050
|
-
layerIds?: string[];
|
|
2051
|
-
}): PixelBuffer;
|
|
2052
|
-
private compositorSources;
|
|
2053
|
-
private sourceIds;
|
|
2054
|
-
private nextSourceId;
|
|
2055
|
-
/** Changes whenever the Background's source pixels can have changed. */
|
|
2056
|
-
private sourceVersion;
|
|
2057
|
-
/** The pixels a pixel layer or smart object composites (the decoded source for the Background). */
|
|
2058
|
-
private surfaceOf;
|
|
2059
|
-
/**
|
|
2060
|
-
* The source image as a surface (cached): host-supplied sample pixels first, then the decoded
|
|
2061
|
-
* element, then pixels read back for the selection tools.
|
|
2062
|
-
*/
|
|
2063
|
-
private sourceSurface;
|
|
2064
|
-
private opaqueCache;
|
|
2065
|
-
/** Whether every source pixel is opaque (some legacy renders depend on it). */
|
|
2066
|
-
private sourceIsOpaque;
|
|
2067
|
-
/** Synchronously reads the source element's pixels through a canvas, or `null`. */
|
|
2068
|
-
private decodeSource;
|
|
2069
|
-
/** Records one undo step and applies a new stack (and any other state change in `extra`). */
|
|
2070
|
-
private commitLayers;
|
|
2071
|
-
/** The default position of a new layer: above the active layer, else the top of the stack. */
|
|
2072
|
-
private newLayerPlacement;
|
|
2073
|
-
/**
|
|
2074
|
-
* Adds a pixel layer (one undo step) and makes it active: empty, filled with `color` over the
|
|
2075
|
-
* canvas, or holding `pixels` placed at `x`, `y`. Goes above the active layer unless placed.
|
|
2076
|
-
* Returns its id.
|
|
2077
|
-
*/
|
|
2078
|
-
addPixelLayer(init?: PixelLayerInit): string;
|
|
2079
|
-
/**
|
|
2080
|
-
* `addPixelLayer` from an image: a PNG data URL or base64 PNG is decoded without a canvas;
|
|
2081
|
-
* other formats and URLs need a browser. Returns the new layer id.
|
|
2082
|
-
*/
|
|
2083
|
-
addPixelLayerFromImage(image: string, init?: Omit<PixelLayerInit, 'pixels' | 'color'>): Promise<string>;
|
|
2084
|
-
/** RGBA pixels of an image given as a data URL, base64 PNG or URL. */
|
|
2085
|
-
decodeImage(image: string): Promise<PixelBuffer>;
|
|
2086
|
-
private nextLayerName;
|
|
2087
|
-
/** Duplicates a layer (with its children) directly above it, as one undo step. Returns the copy's id. */
|
|
2088
|
-
duplicateLayer(id: string, name?: string): string;
|
|
2089
|
-
/** Deletes a layer (refused when locked), as one undo step. */
|
|
2090
|
-
removeLayer(id: string): void;
|
|
2091
|
-
/** Moves a layer above / below another, or into a group, as one undo step. Returns its new parent and index. */
|
|
2092
|
-
moveLayer(id: string, placement: LayerPlacement): {
|
|
2093
|
-
parentId: string | null;
|
|
2094
|
-
index: number;
|
|
2095
|
-
};
|
|
2096
|
-
/**
|
|
2097
|
-
* Changes name, visibility, opacity, fill, blend, clipping, locks or (groups) collapsed state, as
|
|
2098
|
-
* one undo step (`commitToHistory = false` for the moves of a slider drag). Returns the layer.
|
|
2099
|
-
*/
|
|
2100
|
-
setLayerProperties(id: string, props: LayerProperties, commitToHistory?: boolean): ImageLayer;
|
|
2101
|
-
/** Adds an empty pass-through group above the active layer (or at `placement`) and makes it active. Returns its id. */
|
|
2102
|
-
addGroup(init?: LayerPlacement & {
|
|
2103
|
-
name?: string;
|
|
2104
|
-
blend?: LayerBlendMode;
|
|
2105
|
-
}): string;
|
|
2106
|
-
/** Puts sibling layers into a new group (one undo step). Returns the group id. */
|
|
2107
|
-
groupLayers(ids: string[], name?: string): string;
|
|
2108
|
-
/** Replaces a group by its children (one undo step). Returns the child ids, bottom to top. */
|
|
2109
|
-
ungroupLayer(id: string): string[];
|
|
2110
|
-
/**
|
|
2111
|
-
* Moves a pixel layer to an absolute offset (`x`, `y`) or by `dx`, `dy`, as one undo step
|
|
2112
|
-
* (`commitToHistory = false` for the moves of a drag). Returns the offset and document bounds.
|
|
2113
|
-
*/
|
|
2114
|
-
offsetLayer(id: string, move: {
|
|
2115
|
-
x?: number;
|
|
2116
|
-
y?: number;
|
|
2117
|
-
dx?: number;
|
|
2118
|
-
dy?: number;
|
|
2119
|
-
}, commitToHistory?: boolean): {
|
|
2120
|
-
offset: {
|
|
2121
|
-
x: number;
|
|
2122
|
-
y: number;
|
|
2123
|
-
};
|
|
2124
|
-
bounds: CropBox | null;
|
|
2125
|
-
};
|
|
2126
|
-
/**
|
|
2127
|
-
* Adds a mask to a layer (one undo step): `reveal-all` (white), `hide-all` (black) or
|
|
2128
|
-
* `selection` (the selection's coverage). Replaces an existing mask. Makes the mask the paint
|
|
2129
|
-
* target when the layer is active.
|
|
2130
|
-
*/
|
|
2131
|
-
addLayerMask(id: string, from?: 'reveal-all' | 'hide-all' | 'selection', props?: LayerMaskProps): RasterMask;
|
|
2132
|
-
/** Removes a layer's mask (one undo step). */
|
|
2133
|
-
removeLayerMask(id: string): void;
|
|
2134
|
-
/** Changes any layer mask's density, feather, enabled or linked flag (pixels kept). Returns the mask. */
|
|
2135
|
-
setLayerMaskProps(id: string, props: LayerMaskProps, commitToHistory?: boolean): RasterMask;
|
|
2136
|
-
/**
|
|
2137
|
-
* Bakes a pixel layer's mask into its pixels (alpha × coverage, including density, feather or
|
|
2138
|
-
* the depth map) and removes the mask, as one undo step.
|
|
2139
|
-
*/
|
|
2140
|
-
applyLayerMask(id: string): Promise<void>;
|
|
2141
|
-
/**
|
|
2142
|
-
* Layer via Copy (or via Cut): a new pixel layer with the selected pixels of a pixel layer (the
|
|
2143
|
-
* active one by default), directly above it, as one undo step. Returns the new id.
|
|
2144
|
-
*/
|
|
2145
|
-
layerViaCopy(options?: {
|
|
2146
|
-
layerId?: string;
|
|
2147
|
-
cut?: boolean;
|
|
2148
|
-
name?: string;
|
|
2149
|
-
}): string;
|
|
2150
|
-
private openTransform;
|
|
2151
|
-
/** The Free Transform in progress (see `beginFreeTransform`), or `null`. */
|
|
2152
|
-
getFreeTransform(): FreeTransformSession | null;
|
|
2153
|
-
private transformHost;
|
|
2154
|
-
/**
|
|
2155
|
-
* Starts a Free Transform (Edit › Free Transform, Transform Selection, or a transform of a Layer
|
|
2156
|
-
* via Copy): of the layer's pixels with its linked mask, an unlinked mask alone, the selected
|
|
2157
|
-
* pixels or just the selection outline (see `FreeTransformInit`). Change the geometry with
|
|
2158
|
-
* `session.update` (live preview, no history), then `commit()` (one undo step) or `cancel()`.
|
|
2159
|
-
* Refused while another transform is open.
|
|
2160
|
-
*/
|
|
2161
|
-
beginFreeTransform(init?: FreeTransformInit): FreeTransformSession;
|
|
2162
|
-
/**
|
|
2163
|
-
* Transforms in one step (agents, scripts): begins a Free Transform for `spec`, sets its corners
|
|
2164
|
-
* from exactly one of `matrix` (document-space affine), `corners` (where the frame's corners go:
|
|
2165
|
-
* distort / perspective) or `params` (scale, rotate, skew and move about a reference point), and
|
|
2166
|
-
* commits it as one undo step. Returns what changed and the new bounds.
|
|
2167
|
-
*/
|
|
2168
|
-
transformLayer(spec: FreeTransformInit & {
|
|
2169
|
-
matrix?: AffineMatrix;
|
|
2170
|
-
corners?: Quad;
|
|
2171
|
-
params?: TransformParams;
|
|
2172
|
-
warp?: WarpMesh | WarpPreset | null;
|
|
2173
|
-
}): FreeTransformResult;
|
|
2174
|
-
/** Flips the layer (or its selected pixels, or the outline) about the frame's centre, exactly (one undo step). */
|
|
2175
|
-
flipLayer(axis: 'horizontal' | 'vertical', init?: FreeTransformInit): FreeTransformResult;
|
|
2176
|
-
/**
|
|
2177
|
-
* Rotates by a quarter turn (90 clockwise, −90 counter-clockwise) or 180 about the frame's
|
|
2178
|
-
* centre, snapped so pixels land on whole pixels: exact, no resampling (one undo step).
|
|
2179
|
-
*/
|
|
2180
|
-
rotateLayer90(turn: 90 | -90 | 180, init?: FreeTransformInit): FreeTransformResult;
|
|
2181
|
-
/** Adds a `develop` or `blur` filter to a pixel layer (one undo step). Returns the layer's filters. */
|
|
2182
|
-
addLayerFilter(id: string, filter: Partial<LayerFilter> & {
|
|
2183
|
-
kind: LayerFilter['kind'];
|
|
2184
|
-
}): LayerFilter[];
|
|
2185
|
-
/** Changes one filter (one undo step, or none with `commitToHistory = false` during a drag). Returns the filters. */
|
|
2186
|
-
updateLayerFilter(id: string, filterId: string, changes: Record<string, unknown>, commitToHistory?: boolean): LayerFilter[];
|
|
2187
|
-
/** Removes one filter (one undo step). Returns the remaining filters. */
|
|
2188
|
-
removeLayerFilter(id: string, filterId: string): LayerFilter[];
|
|
2189
|
-
private get canvasSize();
|
|
2190
|
-
/**
|
|
2191
|
-
* Layer › Smart Objects › Convert to Smart Object (one undo step): sibling layers (default the
|
|
2192
|
-
* active one) become one smart object at the topmost one's position. A single pixel layer keeps
|
|
2193
|
-
* its id and properties and its filters become smart filters (it renders exactly as before);
|
|
2194
|
-
* anything else nests as a layer document. Returns the smart object's id.
|
|
2195
|
-
*/
|
|
2196
|
-
convertToSmartObject(ids?: string[], options?: {
|
|
2197
|
-
name?: string;
|
|
2198
|
-
}): string;
|
|
2199
|
-
/** Layer › Smart Objects › Rasterize (one undo step): the smart object becomes a pixel layer holding what it renders. */
|
|
2200
|
-
rasterizeSmartObject(id: string): string;
|
|
2201
|
-
/** A smart object's contents, placement and smart filters as plain data (see `SmartObjectInfo`). */
|
|
2202
|
-
getSmartObject(id: string): SmartObjectInfo;
|
|
2203
|
-
/**
|
|
2204
|
-
* Sets a smart object's placement (one undo step, or none with `commitToHistory = false` during a
|
|
2205
|
-
* drag): where the contents' corners land, an optional warp in contents pixels and the
|
|
2206
|
-
* interpolation. The contents render again from the source; a linked mask follows a warp-free
|
|
2207
|
-
* change. Returns the new placement summary.
|
|
2208
|
-
*/
|
|
2209
|
-
setSmartObjectPlacement(id: string, placement: SmartPlacement, commitToHistory?: boolean): SmartObjectInfo['placement'] & {
|
|
2210
|
-
masksMoved: boolean;
|
|
2211
|
-
};
|
|
2212
|
-
/**
|
|
2213
|
-
* Sets a smart object's transform absolutely (one undo step): exactly one of `corners` (where the
|
|
2214
|
-
* contents' corners land), `matrix` (contents pixels → document) or the numbers (`scaleX`,
|
|
2215
|
-
* `scaleY` in percent of the contents' own size, `rotate`, `skewX`, `skewY`, and `x`, `y` where
|
|
2216
|
-
* the contents' centre goes, default where it is now); plus, optionally, a warp (a preset, a mesh
|
|
2217
|
-
* in contents pixels, or `null` to remove it) and the interpolation. Unlike `transformLayer`,
|
|
2218
|
-
* nothing is relative to the current transform.
|
|
2219
|
-
*/
|
|
2220
|
-
setSmartObjectTransform(id: string, spec: {
|
|
2221
|
-
corners?: Quad;
|
|
2222
|
-
matrix?: AffineMatrix;
|
|
2223
|
-
scaleX?: number;
|
|
2224
|
-
scaleY?: number;
|
|
2225
|
-
rotate?: number;
|
|
2226
|
-
skewX?: number;
|
|
2227
|
-
skewY?: number;
|
|
2228
|
-
x?: number;
|
|
2229
|
-
y?: number;
|
|
2230
|
-
warp?: WarpMesh | WarpPreset | null;
|
|
2231
|
-
interpolation?: Interpolation;
|
|
2232
|
-
}): SmartObjectInfo['placement'] & {
|
|
2233
|
-
masksMoved: boolean;
|
|
2234
|
-
};
|
|
2235
|
-
/**
|
|
2236
|
-
* Layer › Smart Objects › Replace Contents (one undo step): new contents for the smart object and
|
|
2237
|
-
* every instance linked to it, from RGBA pixels, PSD bytes (a layer document) or contents. Each
|
|
2238
|
-
* instance keeps its scale and rotation about the contents' centre. Returns the contents id and
|
|
2239
|
-
* the layers that changed.
|
|
2240
|
-
*/
|
|
2241
|
-
replaceSmartObjectContents(id: string, source: {
|
|
2242
|
-
pixels: PixelBuffer;
|
|
2243
|
-
name?: string;
|
|
2244
|
-
} | {
|
|
2245
|
-
psd: Uint8Array;
|
|
2246
|
-
name?: string;
|
|
2247
|
-
} | {
|
|
2248
|
-
contents: SmartContents;
|
|
2249
|
-
}): {
|
|
2250
|
-
contentsId: string;
|
|
2251
|
-
width: number;
|
|
2252
|
-
height: number;
|
|
2253
|
-
layerIds: string[];
|
|
2254
|
-
};
|
|
2255
|
-
/** `replaceSmartObjectContents` from an image (PNG data URL or base64 decodes anywhere; other formats need a browser). */
|
|
2256
|
-
replaceSmartObjectContentsFromImage(id: string, image: string, name?: string): Promise<{
|
|
2257
|
-
contentsId: string;
|
|
2258
|
-
width: number;
|
|
2259
|
-
height: number;
|
|
2260
|
-
layerIds: string[];
|
|
2261
|
-
}>;
|
|
2262
|
-
/**
|
|
2263
|
-
* Layer › Smart Objects › Export Contents: the file the contents came from while unedited, else a
|
|
2264
|
-
* PNG (raster contents) or a PSD / PSB of the nested document. Returns the file name, MIME type
|
|
2265
|
-
* and bytes.
|
|
2266
|
-
*/
|
|
2267
|
-
exportSmartObjectContents(id: string): {
|
|
2268
|
-
name: string;
|
|
2269
|
-
mimeType: string;
|
|
2270
|
-
bytes: Uint8Array;
|
|
2271
|
-
};
|
|
2272
|
-
/**
|
|
2273
|
-
* Layer › Smart Objects › New Smart Object via Copy (`linked: false`: independent contents) or a
|
|
2274
|
-
* linked duplicate (`linked: true`: edits to the contents show in both), directly above, as one
|
|
2275
|
-
* undo step. Returns the copy's id.
|
|
2276
|
-
*/
|
|
2277
|
-
copySmartObject(id: string, linked?: boolean, name?: string): string;
|
|
2278
|
-
/** Adds a smart filter (`develop` or `blur`, with `blend` and `opacity`) at `index` (default the top), as one undo step. */
|
|
2279
|
-
addSmartFilter(id: string, filter: Record<string, unknown> & {
|
|
2280
|
-
kind: string;
|
|
2281
|
-
}, index?: number): SmartFilter;
|
|
2282
|
-
/** Changes one smart filter (one undo step, or none with `commitToHistory = false` during a drag). */
|
|
2283
|
-
updateSmartFilter(id: string, filterId: string, changes: Record<string, unknown>, commitToHistory?: boolean): SmartFilter;
|
|
2284
|
-
/** Removes one smart filter (one undo step). Returns the remaining filters. */
|
|
2285
|
-
removeSmartFilter(id: string, filterId: string): SmartFilter[];
|
|
2286
|
-
/** Moves one smart filter to `index` (0 = bottom, applied first), as one undo step. Returns the filters. */
|
|
2287
|
-
moveSmartFilter(id: string, filterId: string, index: number): SmartFilter[];
|
|
2288
|
-
/** Turns a smart object's whole filter stack on or off (one undo step). */
|
|
2289
|
-
setSmartFiltersEnabled(id: string, enabled: boolean): boolean;
|
|
2290
|
-
/**
|
|
2291
|
-
* Sets the smart filter mask (one undo step): `reveal-all`, `hide-all`, `selection` (the
|
|
2292
|
-
* selection's coverage), or `none` to remove it; `props` sets density, feather, enabled and linked.
|
|
2293
|
-
* Painting it targets channel `filter-mask`. Returns the mask, or `null` when removed.
|
|
2294
|
-
*/
|
|
2295
|
-
setSmartFilterMask(id: string, from: 'reveal-all' | 'hide-all' | 'selection' | 'none' | 'keep', props?: LayerMaskProps, commitToHistory?: boolean): RasterMask | null;
|
|
2296
|
-
/**
|
|
2297
|
-
* Decodes smart object contents that came as files the synchronous decoders cannot read (a JPEG
|
|
2298
|
-
* or TIFF embedded in a PSD), through the browser's image decoder. No undo step: the pixels on
|
|
2299
|
-
* screen do not change. Returns the contents ids still undecoded.
|
|
2300
|
-
*/
|
|
2301
|
-
prepareSmartObjects(): Promise<string[]>;
|
|
2302
|
-
private contentsStack;
|
|
2303
|
-
/** The smart objects whose contents are open (outermost first); empty when the document itself is shown. */
|
|
2304
|
-
getEditingContents(): Array<{
|
|
2305
|
-
layerId: string;
|
|
2306
|
-
name: string;
|
|
2307
|
-
}>;
|
|
2308
|
-
/**
|
|
2309
|
-
* Layer › Smart Objects › Edit Contents: shows the smart object's contents as a document of their
|
|
2310
|
-
* own (a layer document, or raster contents as one pixel layer), with their own undo history.
|
|
2311
|
-
* Every editor operation and tool then works on the contents until `closeSmartObjectContents`.
|
|
2312
|
-
* Contents can nest. Returns the contents' size and layer ids.
|
|
2313
|
-
*/
|
|
2314
|
-
editSmartObjectContents(id: string): {
|
|
2315
|
-
layerId: string;
|
|
2316
|
-
depth: number;
|
|
2317
|
-
width: number;
|
|
2318
|
-
height: number;
|
|
2319
|
-
layerIds: string[];
|
|
2320
|
-
};
|
|
2321
|
-
/**
|
|
2322
|
-
* Closes the innermost open contents: with `save` (default) the edited layers become the smart
|
|
2323
|
-
* object's contents, and it and every linked instance render again (one undo step in the
|
|
2324
|
-
* document); without, the edits are dropped. Returns the smart object and the layers that changed.
|
|
2325
|
-
*/
|
|
2326
|
-
closeSmartObjectContents(save?: boolean): {
|
|
2327
|
-
layerId: string;
|
|
2328
|
-
changed: boolean;
|
|
2329
|
-
layerIds: string[];
|
|
2330
|
-
};
|
|
2331
|
-
/** The document's own layers (not the contents open for editing). */
|
|
2332
|
-
private rootLayers;
|
|
2333
|
-
/** Drops every open contents edit (loading another document). */
|
|
2334
|
-
private abandonContents;
|
|
2335
|
-
/** A layer's effects (an empty, enabled list when it has none). */
|
|
2336
|
-
getLayerEffects(id: string): LayerEffects;
|
|
2337
|
-
/**
|
|
2338
|
-
* Adds an effect of `kind` with Photoshop's defaults and `params` applied (one undo step), at
|
|
2339
|
-
* `index` in the layer's effect list (default the end). Returns the new effect and the effects.
|
|
2340
|
-
*/
|
|
2341
|
-
addLayerEffect(id: string, kind: LayerEffectKind, params?: Record<string, unknown>, index?: number): {
|
|
2342
|
-
effect: LayerEffect;
|
|
2343
|
-
effects: LayerEffects;
|
|
2344
|
-
};
|
|
2345
|
-
/** Changes one effect (one undo step, or none with `commitToHistory = false` during a drag). Returns the effects. */
|
|
2346
|
-
updateLayerEffect(id: string, effectId: string, changes: Record<string, unknown>, commitToHistory?: boolean): LayerEffects;
|
|
2347
|
-
/** Removes one effect (one undo step). Returns the remaining effects. */
|
|
2348
|
-
removeLayerEffect(id: string, effectId: string): LayerEffects;
|
|
2349
|
-
/** Turns a layer's effects on or off as a whole and, when given, sets Scale Effects (one undo step). */
|
|
2350
|
-
setLayerEffectsEnabled(id: string, enabled: boolean, scale?: number, commitToHistory?: boolean): LayerEffects;
|
|
2351
|
-
/** Replaces a layer's effects (one undo step; `null` removes them). Returns the effects. */
|
|
2352
|
-
setLayerEffects(id: string, effects: LayerEffects | null, commitToHistory?: boolean): LayerEffects;
|
|
2353
|
-
private patternIds;
|
|
2354
|
-
/** Changes whenever the document's pattern list is replaced (the compositor then drops its caches). */
|
|
2355
|
-
private patternsVersion;
|
|
2356
|
-
/** The document's patterns (from an opened PSD), besides the built-in ones. */
|
|
2357
|
-
getDocumentPatterns(): EffectPattern[];
|
|
2358
|
-
/** The light effects with "use global light" follow. */
|
|
2359
|
-
getGlobalLight(): GlobalLight;
|
|
2360
|
-
/** Sets the global light (one undo step). `angle` -360..360°, `altitude` 0..90°. Returns it. */
|
|
2361
|
-
setGlobalLight(light: Partial<GlobalLight>, commitToHistory?: boolean): GlobalLight;
|
|
2362
|
-
/** Composites `layers` (in isolation) over `rect` into a surface, loading depth maps first. */
|
|
2363
|
-
private compositeToSurface;
|
|
2364
|
-
/** Document bounds a layer can paint into (pixel content, annotations, or the canvas for the rest). */
|
|
2365
|
-
private paintBounds;
|
|
2366
|
-
/**
|
|
2367
|
-
* Merge Down: composites a layer onto the pixel layer directly below it (which keeps its name,
|
|
2368
|
-
* opacity and blend; masks, fill, filters and both layers' effects are baked), as one undo step.
|
|
2369
|
-
* Returns the merged id.
|
|
2370
|
-
*/
|
|
2371
|
-
mergeDown(id: string): Promise<string>;
|
|
2372
|
-
/**
|
|
2373
|
-
* Merge Visible: the visible top-level layers become one normal pixel layer (at the position of
|
|
2374
|
-
* the lowest of them); hidden layers stay. One undo step. Returns the merged id.
|
|
2375
|
-
*/
|
|
2376
|
-
mergeVisible(): Promise<string>;
|
|
2377
|
-
/** Flatten Image: every visible layer composited into one Background layer; hidden layers are discarded. One undo step. */
|
|
2378
|
-
flattenImage(): Promise<string>;
|
|
2379
|
-
private thumbCache;
|
|
2380
|
-
/**
|
|
2381
|
-
* A small RGBA preview of a pixel layer over the canvas (or of its mask with `mask: true`),
|
|
2382
|
-
* longest side `maxSide` px, point-sampled; `null` for layers without pixels.
|
|
2383
|
-
*/
|
|
2384
|
-
getLayerThumbnail(id: string, options?: {
|
|
2385
|
-
maxSide?: number;
|
|
2386
|
-
mask?: boolean;
|
|
2387
|
-
}): PixelBuffer | null;
|
|
2388
|
-
/** Brush settings, colours and tool options of the paint tools (view state, no undo). */
|
|
2389
|
-
setPaintOptions(options: Partial<Omit<PaintOptions, 'brush' | 'mixer' | 'mixerLoad'>> & {
|
|
2390
|
-
brush?: Partial<BrushSettings>;
|
|
2391
|
-
mixer?: Partial<MixerSettings>;
|
|
2392
|
-
}): PaintOptions;
|
|
2393
|
-
/**
|
|
2394
|
-
* Loads the Mixer Brush's reservoir full with `color` (default the foreground); the picked-up
|
|
2395
|
-
* colour is kept. View state, no undo. Returns the brush load.
|
|
2396
|
-
*/
|
|
2397
|
-
loadMixerBrush(color?: string | number[]): MixerLoad;
|
|
2398
|
-
/** Cleans the Mixer Brush: empties the pickup well (the reservoir is kept). Returns the brush load. */
|
|
2399
|
-
cleanMixerBrush(): MixerLoad;
|
|
2400
|
-
/** Empties the Mixer Brush entirely (no reservoir, nothing picked up). Returns the brush load. */
|
|
2401
|
-
emptyMixerBrush(): MixerLoad;
|
|
2402
|
-
/** D: black foreground, white background. */
|
|
2403
|
-
resetPaintColors(): void;
|
|
2404
|
-
/** X: swaps the foreground and background colours. */
|
|
2405
|
-
swapPaintColors(): void;
|
|
2406
|
-
/** Resolves and validates what a stroke, fill or clear paints into. */
|
|
2407
|
-
private paintTarget;
|
|
2408
|
-
/** The layer with its pixels (or mask) replaced by `surface`. */
|
|
2409
|
-
private withSurface;
|
|
2410
|
-
/**
|
|
2411
|
-
* Starts a brush or eraser stroke on a layer's pixels or mask (default: the active layer and
|
|
2412
|
-
* target, the paint options' brush and colours). Feed points with `push`, finish with `end()`
|
|
2413
|
-
* (one undo step for the whole stroke) or `cancel()`. While it runs, the stack shows the stroke
|
|
2414
|
-
* without recording history.
|
|
2415
|
-
*/
|
|
2416
|
-
beginStroke(init?: StrokeInit): PaintStrokeSession;
|
|
2417
|
-
/** A Mixer Brush stroke's start: the settings, and the load (refilled when asked or set to). */
|
|
2418
|
-
private mixerStroke;
|
|
2419
|
-
/** @internal Shows a stroke's live surface (no history). */
|
|
2420
|
-
_strokeUpdate(layerId: string, channel: LayerTarget, surface: TiledSurface, rects: CropBox[]): void;
|
|
2421
|
-
/** @internal Commits a finished stroke as one undo step (`before` is the pre-stroke state). */
|
|
2422
|
-
_strokeCommit(before: HistoryEntryHandle, layerId: string, channel: LayerTarget, surface: TiledSurface | null): void;
|
|
2423
|
-
/** @internal The pre-stroke snapshot. */
|
|
2424
|
-
_captureForStroke(): HistoryEntryHandle;
|
|
2425
|
-
/**
|
|
2426
|
-
* Paints a whole stroke in one call (agents, replays): `points` in document pixels with optional
|
|
2427
|
-
* pressure, through the brush, eraser or Mixer Brush. One undo step. Returns the layer, channel, the changed
|
|
2428
|
-
* document bounds and the number of dabs.
|
|
2429
|
-
*/
|
|
2430
|
-
paintStroke(init: StrokeInit & {
|
|
2431
|
-
points: StrokePoint[];
|
|
2432
|
-
}): PaintStrokeResult;
|
|
2433
|
-
/**
|
|
2434
|
-
* Edit › Fill: fills the selection (or, without one or with `useSelection: false`, the whole
|
|
2435
|
-
* canvas) on a layer's pixels or mask with a colour (default the foreground), at `opacity` with
|
|
2436
|
-
* `blend`. One undo step. Returns the changed bounds.
|
|
2437
|
-
*/
|
|
2438
|
-
fillPixels(options?: FillOptions): PaintStrokeResult;
|
|
2439
|
-
/**
|
|
2440
|
-
* Edit › Clear: removes the selected pixels (alpha to 0; on a transparency-locked layer or a mask
|
|
2441
|
-
* it fills with the background colour). Without a selection (or with `useSelection: false`) the
|
|
2442
|
-
* whole canvas. One undo step. Returns the changed bounds.
|
|
2443
|
-
*/
|
|
2444
|
-
clearPixels(options?: Omit<FillOptions, 'color' | 'blend'>): PaintStrokeResult;
|
|
2445
|
-
private fillOrClear;
|
|
2446
|
-
/** The pixel layer the base sliders edit: the active pixel layer, else the Background. */
|
|
2447
|
-
private developLayer;
|
|
2448
|
-
/**
|
|
2449
|
-
* Sets base adjustment values as one undo step (unless `commitToHistory` is false). The base
|
|
2450
|
-
* sliders edit the `develop` filter of the active pixel layer (or the Background), `blur` its
|
|
2451
|
-
* blur filter (or `legacyOutputBlur` in migrated documents), `opacity` the output opacity, and
|
|
2452
|
-
* `layers` replaces the adjustment layers.
|
|
2453
|
-
*/
|
|
2454
|
-
setAdjustments(partial: Partial<ImageAdjustments>, commitToHistory?: boolean): void;
|
|
2455
|
-
/** True when the adjustments use an older rendering process than {@link LATEST_PROCESS_VERSION}. */
|
|
2456
|
-
get isProcessOutdated(): boolean;
|
|
2457
|
-
/**
|
|
2458
|
-
* Update to Current Process: re-interprets the current adjustment values with the latest
|
|
2459
|
-
* rendering process (one undo step). Returns false when already current.
|
|
2460
|
-
*/
|
|
2461
|
-
upgradeProcess(): boolean;
|
|
2462
|
-
/** Resets the base sliders (latest process). Adjustment layers are kept; see `clearAdjustmentLayers`. */
|
|
2463
|
-
resetAdjustments(): void;
|
|
2464
|
-
/** The adjustment layers in stack order, bottom (first) to top (last). */
|
|
2465
|
-
getAdjustmentLayers(): AdjustmentLayer[];
|
|
2466
|
-
getAdjustmentLayer(id: string): AdjustmentLayer | undefined;
|
|
2467
|
-
private adjustmentNodes;
|
|
2468
|
-
/**
|
|
2469
|
-
* Where a new layer goes when no position is given: directly above the topmost layer that is
|
|
2470
|
-
* not an annotation, so it adjusts what adjustment layers always adjusted (annotations stay on top).
|
|
2471
|
-
*/
|
|
2472
|
-
private defaultInsertIndex;
|
|
2473
|
-
/** Inserts `node` by `aboveId` / `parentId` / adjustment index / default position. */
|
|
2474
|
-
private placeLayer;
|
|
2475
|
-
/** `setAdjustments({ layers })`: updates nodes by id in place, removes missing ones, adds new ones. */
|
|
2476
|
-
private replaceAdjustmentNodes;
|
|
2477
|
-
/**
|
|
2478
|
-
* Adds an adjustment layer and returns its id, as one undo step. With no position it goes
|
|
2479
|
-
* above the other adjustment layers (or, without any, above the topmost non-annotation layer,
|
|
2480
|
-
* so annotations stay on top); `index` counts adjustment layers (0 = below the others);
|
|
2481
|
-
* `aboveId` / `parentId` place it anywhere in the stack. `kind` alone gives neutral parameters.
|
|
2482
|
-
*/
|
|
2483
|
-
addAdjustmentLayer<K extends AdjustmentKind>(init: K | AdjustmentLayerInit<K>, index?: number): string;
|
|
2484
|
-
/**
|
|
2485
|
-
* Updates a layer (`params` merged into the current ones, then normalised). Pass
|
|
2486
|
-
* `commitToHistory = false` for the moves of a drag after recording its start once.
|
|
2487
|
-
* Returns false for an unknown id.
|
|
2488
|
-
*/
|
|
2489
|
-
updateAdjustmentLayer(id: string, update: AdjustmentLayerUpdate, commitToHistory?: boolean): boolean;
|
|
2490
|
-
/** Removes a layer as one undo step. Returns false for an unknown id. */
|
|
2491
|
-
removeAdjustmentLayer(id: string): boolean;
|
|
2492
|
-
private moveAdjustmentNode;
|
|
2493
|
-
/** Moves a layer to `toIndex` among the adjustment layers (0 = bottom) as one undo step. Returns false if nothing moved. */
|
|
2494
|
-
moveAdjustmentLayer(id: string, toIndex: number): boolean;
|
|
2495
|
-
/** Shows or hides a layer (flips it without `enabled`) as one undo step. */
|
|
2496
|
-
toggleAdjustmentLayer(id: string, enabled?: boolean): boolean;
|
|
2497
|
-
/** Removes every adjustment layer as one undo step. */
|
|
2498
|
-
clearAdjustmentLayers(): void;
|
|
2499
|
-
/** The active selection, or `null`. */
|
|
2500
|
-
getSelection(): SelectionMask | null;
|
|
2501
|
-
get hasSelection(): boolean;
|
|
2502
|
-
private get naturalSize();
|
|
2503
|
-
private dropMismatchedSelection;
|
|
2504
|
-
/**
|
|
2505
|
-
* Replaces the selection, or combines `mask` with it by `mode`, as one undo step. A mask of a
|
|
2506
|
-
* different size (e.g. an AI segmentation at another resolution) is resampled to the image.
|
|
2507
|
-
* Returns false when nothing changed.
|
|
2508
|
-
*/
|
|
2509
|
-
setSelection(mask: SelectionMask | null, mode?: SelectionMode): boolean;
|
|
2510
|
-
/** Select › All. */
|
|
2511
|
-
selectAll(): boolean;
|
|
2512
|
-
/** Select › Deselect. */
|
|
2513
|
-
deselect(): boolean;
|
|
2514
|
-
/** Select › Inverse (with nothing selected, selects everything). */
|
|
2515
|
-
invertSelection(): boolean;
|
|
2516
|
-
private shapeCommand;
|
|
2517
|
-
/** Rectangular marquee in natural image pixels. */
|
|
2518
|
-
selectRect(rect: CropBox, options?: SelectionCommandOptions & ShapeSelectionOptions): boolean;
|
|
2519
|
-
/** Elliptical marquee inscribed in `rect`. */
|
|
2520
|
-
selectEllipse(rect: CropBox, options?: SelectionCommandOptions & ShapeSelectionOptions): boolean;
|
|
2521
|
-
/** Lasso / polygonal lasso. */
|
|
2522
|
-
selectPolygon(points: ImagePoint[], options?: SelectionCommandOptions & ShapeSelectionOptions): boolean;
|
|
2523
|
-
/**
|
|
2524
|
-
* Supplies the pixels the selection tools sample (natural size RGBA), e.g. decoded in a worker
|
|
2525
|
-
* or in a test; `null` goes back to reading the source image. Without a canvas (Node, workers)
|
|
2526
|
-
* these are also the Background layer's pixels.
|
|
2527
|
-
*/
|
|
2528
|
-
setSamplePixels(pixels: PixelBuffer | null): void;
|
|
2529
|
-
/**
|
|
2530
|
-
* The pixels the selection tools sample: the source image at natural size, or with
|
|
2531
|
-
* `sampleMerged` the composite of the layers (no crop, rotation or annotations). `null`
|
|
2532
|
-
* without pixel access (no DOM, tainted canvas).
|
|
2533
|
-
*/
|
|
2534
|
-
getSamplePixels(options?: SampleOptions): Promise<PixelBuffer | null>;
|
|
2535
|
-
private requirePixels;
|
|
2536
|
-
/**
|
|
2537
|
-
* Magic wand at `point` (natural image pixels). Resolves to the resulting selection (null when
|
|
2538
|
-
* nothing is selected).
|
|
2539
|
-
*/
|
|
2540
|
-
magicWand(point: ImagePoint, options?: MagicWandOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
2541
|
-
/** Select › Color Range with colour samples (`#rrggbb` or `[r, g, b]`, optionally where they were picked). */
|
|
2542
|
-
selectColorRange(samples: ColorRangeSample[], options?: ColorRangeOptions & SelectionCommandOptions & SampleOptions): Promise<SelectionMask | null>;
|
|
2543
|
-
/** Select › Modify: grow, shrink, feather, border or smooth by `radius` pixels (one undo step). */
|
|
2544
|
-
modifySelection(op: SelectionModifyOp, radius: number): boolean;
|
|
2545
|
-
/**
|
|
2546
|
-
* Refine Edge: snaps the selection (e.g. a coarse AI mask loaded with `loadSelectionFromImage`)
|
|
2547
|
-
* to the image's edges with a guided filter, then smooth / feather / contrast / shift edge.
|
|
2548
|
-
*/
|
|
2549
|
-
refineSelection(params: RefineEdgeParams, options?: SampleOptions): Promise<boolean>;
|
|
2550
|
-
/**
|
|
2551
|
-
* Loads a selection from a mask image (an AI segmentation, a saved mask): a data URL / URL or
|
|
2552
|
-
* RGBA pixels, by luminance (white = selected) or a channel. Any size; it is resampled.
|
|
2553
|
-
*/
|
|
2554
|
-
loadSelectionFromImage(source: string | PixelBuffer, options?: {
|
|
2555
|
-
channel?: SelectionChannel;
|
|
2556
|
-
invert?: boolean;
|
|
2557
|
-
threshold?: number;
|
|
2558
|
-
mode?: SelectionMode;
|
|
2559
|
-
}): Promise<SelectionMask | null>;
|
|
2560
|
-
/** Quick Mask view (tints the unselected area). View state: no undo step. */
|
|
2561
|
-
setQuickMask(on: boolean): void;
|
|
2562
|
-
private maskFromSelection;
|
|
2563
|
-
/**
|
|
2564
|
-
* Adds the selection as the layer's mask (Reveal Selection), replacing any mask, as one undo
|
|
2565
|
-
* step. Without a selection, returns false.
|
|
2566
|
-
*/
|
|
2567
|
-
applySelectionAsLayerMask(layerId: string, props?: LayerMaskProps): boolean;
|
|
2568
|
-
private setLayerMask;
|
|
2569
|
-
/** Sets (from a selection-shaped mask) or removes (`null`) a layer's mask as one undo step. */
|
|
2570
|
-
setAdjustmentLayerMask(layerId: string, mask: SelectionMask | null, props?: LayerMaskProps): boolean;
|
|
2571
|
-
/** Changes a layer mask's density (0..1), feather (px) or enabled flag; the mask pixels are kept. */
|
|
2572
|
-
setAdjustmentLayerMaskProps(layerId: string, props: LayerMaskProps, commitToHistory?: boolean): boolean;
|
|
2573
|
-
/** Load Selection from a layer mask (its pixels; density and feather are not applied). */
|
|
2574
|
-
selectionFromLayerMask(layerId: string, mode?: SelectionMode): boolean;
|
|
2575
|
-
/**
|
|
2576
|
-
* Histogram of the last rendered preview (after adjustments and layers, before annotations),
|
|
2577
|
-
* or `null` before the first render or without canvas pixel access.
|
|
2578
|
-
*/
|
|
2579
|
-
getHistogram(): ImageHistogram | null;
|
|
2580
|
-
/** Calls `listener` now and whenever a render produces a new preview histogram. */
|
|
2581
|
-
subscribeHistogram(listener: (histogram: ImageHistogram | null) => void): () => void;
|
|
2582
|
-
/** Sets the depth mask (a parametric mask on the active pixel layer, or the Background) as one undo step. */
|
|
2583
|
-
setDepthMask(partial: Partial<DepthMaskOptions>): void;
|
|
2584
|
-
resetDepthMask(): void;
|
|
2585
|
-
private annotationLayer;
|
|
2586
|
-
/** Adds an annotation as its own layer (top of the stack unless `aboveId` is given). */
|
|
2587
|
-
addAnnotation(annotation: CreateAnnotationPayload, placement?: AnnotationPlacement): string;
|
|
2588
|
-
updateAnnotation(id: string, partial: Partial<Annotation>, commitToHistory?: boolean): void;
|
|
2589
|
-
removeAnnotation(id: string): void;
|
|
2590
|
-
clearAnnotations(): void;
|
|
2591
|
-
selectAnnotation(id: string | null): void;
|
|
2592
|
-
setZoom(zoom: number): void;
|
|
2593
|
-
zoomIn(factor?: number): void;
|
|
2594
|
-
zoomOut(factor?: number): void;
|
|
2595
|
-
resetZoom(): void;
|
|
2596
|
-
setPan(pan: ImagePoint): void;
|
|
2597
|
-
setComparing(comparing: boolean): void;
|
|
2598
|
-
setFit(fit: ImageEditorFit): void;
|
|
2599
|
-
private blankSource;
|
|
2600
|
-
/**
|
|
2601
|
-
* What the renderer draws from: the source image, or, for a document without one (an opened
|
|
2602
|
-
* PSD, a v3 document loaded on its own), a transparent canvas of the document size, since every
|
|
2603
|
-
* pixel then comes from the layers. `null` when there is nothing to draw.
|
|
2604
|
-
*/
|
|
2605
|
-
private drawSource;
|
|
2606
|
-
render(targetCanvas: HTMLCanvasElement, options?: RenderOptions): Promise<void>;
|
|
2607
|
-
renderExport(options?: ExportOptions): Promise<HTMLCanvasElement>;
|
|
2608
|
-
/**
|
|
2609
|
-
* Renders the edited image (adjustments, layers and, by default, annotations) in the
|
|
2610
|
-
* source image's own orientation and frame, ignoring crop, rotation and flips, so it lines
|
|
2611
|
-
* up with natural-pixel coordinates (selections, `select_region`). `scale` ≤ 1 shrinks it.
|
|
2612
|
-
* Returns `null` when no image is loaded.
|
|
2613
|
-
*/
|
|
2614
|
-
renderSourceView(options?: {
|
|
2615
|
-
scale?: number;
|
|
2616
|
-
includeAnnotations?: boolean;
|
|
2617
|
-
}): Promise<HTMLCanvasElement | null>;
|
|
2618
|
-
toDataURL(options?: ExportOptions): Promise<string>;
|
|
2619
|
-
toBlob(options?: ExportOptions): Promise<Blob>;
|
|
2620
|
-
renderMask(options?: {
|
|
2621
|
-
useAnnotations?: boolean;
|
|
2622
|
-
useCrop?: boolean;
|
|
2623
|
-
useSelection?: boolean;
|
|
2624
|
-
}): Promise<HTMLCanvasElement>;
|
|
2625
|
-
toMaskDataURL(options?: {
|
|
2626
|
-
useAnnotations?: boolean;
|
|
2627
|
-
useCrop?: boolean;
|
|
2628
|
-
useSelection?: boolean;
|
|
2629
|
-
}): Promise<string>;
|
|
2630
|
-
/**
|
|
2631
|
-
* Renders the current source image at natural size with no crop, rotation, flip,
|
|
2632
|
-
* adjustments or annotations. This is the image that `toMaskDataURL()` is aligned with
|
|
2633
|
-
* and the space that `applyInpaintedImage` / `applyBackgroundRemovedImage` expect back.
|
|
2634
|
-
*/
|
|
2635
|
-
renderSource(): Promise<HTMLCanvasElement>;
|
|
2636
|
-
/**
|
|
2637
|
-
* The image an AI hook should edit: the source (`toSourceDataURL`) when results replace the
|
|
2638
|
-
* Background, or the composite of the layers without annotations, in the source frame, when
|
|
2639
|
-
* they go to a new layer or mask (see `applyInpaintedImage`).
|
|
2640
|
-
*/
|
|
2641
|
-
toAIInputDataURL(options?: AIResultOptions): Promise<string>;
|
|
2642
|
-
toSourceDataURL(options?: Pick<ExportOptions, 'format' | 'quality'>): Promise<string>;
|
|
2643
|
-
/**
|
|
2644
|
-
* Whether AI results go to layers: the document has more than one pixel layer or group (adjustment
|
|
2645
|
-
* and annotation layers are edits of the image, not images of their own).
|
|
2646
|
-
*/
|
|
2647
|
-
/** `new-layer` in multi-layer documents and documents without a source image, else `replace`. */
|
|
2648
|
-
private defaultAITarget;
|
|
2649
|
-
/** No source image, and no layer reading one (an opened PSD): the layers are the whole document. */
|
|
2650
|
-
private isSourceless;
|
|
2651
|
-
get isMultiLayer(): boolean;
|
|
2652
|
-
/**
|
|
2653
|
-
* Applies an inpainted result (natural image space, see `toSourceDataURL`) as ONE undoable step.
|
|
2654
|
-
* In a document with several layers (see `isMultiLayer`), or with `target: 'new-layer'`, the
|
|
2655
|
-
* result goes to a new pixel layer above the active layer, limited to the selection. Otherwise
|
|
2656
|
-
* (`target: 'replace'`, the single-layer default) it replaces the Background's pixels and clears
|
|
2657
|
-
* the mask annotations, as before. Resolves to the new layer's id in new-layer mode.
|
|
2658
|
-
*/
|
|
2659
|
-
applyInpaintedImage(newDataUrl: string, options?: AIResultOptions): Promise<string | void>;
|
|
2660
|
-
/**
|
|
2661
|
-
* Applies a background-removed result as ONE undoable step. In a document with several layers
|
|
2662
|
-
* (or with `target: 'new-layer'`) the result's alpha becomes the mask of the active pixel layer
|
|
2663
|
-
* (or the Background), replacing its mask. Otherwise (`target: 'replace'`, the single-layer
|
|
2664
|
-
* default) it replaces the Background's pixels; crop and annotations are kept (rescaled if the
|
|
2665
|
-
* new image has different dimensions). Resolves to the masked layer's id in mask mode.
|
|
2666
|
-
*/
|
|
2667
|
-
applyBackgroundRemovedImage(newDataUrl: string, options?: AIResultOptions): Promise<string | void>;
|
|
2668
|
-
/**
|
|
2669
|
-
* Rasterize Layer: an annotation layer becomes a pixel layer with the same id, name and
|
|
2670
|
-
* properties (needs a canvas), and a pixel layer's filters are baked into its pixels. One undo
|
|
2671
|
-
* step. Returns the layer id.
|
|
2672
|
-
*/
|
|
2673
|
-
rasterizeLayer(id: string): Promise<string>;
|
|
2674
|
-
/** Pixels per inch of the last opened PSD (written back by `toPsd`). */
|
|
2675
|
-
private psdResolution;
|
|
2676
|
-
/**
|
|
2677
|
-
* Opens PSD / PSB bytes as the document (one undo step): the layers replace the stack and the
|
|
2678
|
-
* document has no source image afterwards (every pixel comes from the layers). What the model
|
|
2679
|
-
* cannot hold is approximated or left out; `warnings` says what, naming the layers.
|
|
2680
|
-
* Throws `PsdError` for files that cannot be read at all.
|
|
2681
|
-
*/
|
|
2682
|
-
loadPsd(bytes: Uint8Array): {
|
|
2683
|
-
layerIds: string[];
|
|
2684
|
-
warnings: string[];
|
|
2685
|
-
width: number;
|
|
2686
|
-
height: number;
|
|
2687
|
-
summary: PsdImportResult['summary'];
|
|
2688
|
-
};
|
|
2689
|
-
/**
|
|
2690
|
-
* The document as an 8-bit RGB PSD (PSB above 30 000 px) with real layers, groups, adjustment
|
|
2691
|
-
* layers and masks, in the source frame. Layer filters and parametric (depth) masks are baked
|
|
2692
|
-
* into pixels and masks, annotation layers are rasterized (in a browser; elsewhere they are left
|
|
2693
|
-
* out), and the merged image is our composite. `warnings` lists every such change.
|
|
2694
|
-
*/
|
|
2695
|
-
toPsd(): Promise<{
|
|
2696
|
-
bytes: Uint8Array;
|
|
2697
|
-
warnings: string[];
|
|
2698
|
-
psb: boolean;
|
|
2699
|
-
width: number;
|
|
2700
|
-
height: number;
|
|
2701
|
-
}>;
|
|
2702
|
-
private replaceSource;
|
|
2703
|
-
/**
|
|
2704
|
-
* The serializable state. A document whose layers still have the v1 / v2 shape (the
|
|
2705
|
-
* Background with its sliders and depth mask, adjustment layers, annotations) is written as
|
|
2706
|
-
* v1 / v2 exactly as before; anything else is written as v3 with the layer pixels as PNG
|
|
2707
|
-
* assets. `selection` is included (run-length encoded) only when something is selected.
|
|
2708
|
-
*/
|
|
2709
|
-
toJSON(): SerializedImageEditorState;
|
|
2710
|
-
/**
|
|
2711
|
-
* With `assets: 'external'`, layer pixels go to `store` (each PNG uploaded once per store) and
|
|
2712
|
-
* the v3 document holds the store's references. Old-shape documents have no assets either way.
|
|
2713
|
-
*/
|
|
2714
|
-
toJSON(options: {
|
|
2715
|
-
assets: 'external';
|
|
2716
|
-
store: ImageEditorAssetStore;
|
|
2717
|
-
}): Promise<SerializedImageEditorState>;
|
|
2718
|
-
/**
|
|
2719
|
-
* Loads a stored state whose v3 assets may live in an asset store (references other than data
|
|
2720
|
-
* URLs are fetched with `store.get`), as one undo step. Assets that cannot be fetched are left
|
|
2721
|
-
* out and listed in `lastLoadProblems`.
|
|
2722
|
-
*/
|
|
2723
|
-
loadJSONAsync(data: SerializedImageEditorState, options?: {
|
|
2724
|
-
store?: ImageEditorAssetStore;
|
|
2725
|
-
}): Promise<void>;
|
|
2726
|
-
/** Loads a stored state of any version (one undo step). */
|
|
2727
|
-
loadJSON(data: SerializedImageEditorState): void;
|
|
2728
|
-
/** Problems found by the last `loadJSON` / `initialState` of a v3 document (unreadable layers or assets). */
|
|
2729
|
-
lastLoadProblems: string[];
|
|
2730
|
-
private applyStored;
|
|
2731
|
-
private serializeState;
|
|
2732
|
-
}
|
|
2733
|
-
/** Bilinear resample of RGBA pixels to `width × height`. */
|
|
2734
|
-
declare function resizePixels(px: PixelBuffer, width: number, height: number): PixelBuffer;
|
|
2735
|
-
/** A colour as RGBA bytes: `#rgb`, `#rrggbb`, `#rrggbbaa` or `[r, g, b, a?]` (0..255). */
|
|
2736
|
-
declare function parseColor(value: string | number[]): [number, number, number, number];
|
|
2737
|
-
/** `#rrggbb` of RGBA bytes (alpha dropped). */
|
|
2738
|
-
declare function toHex(c: readonly number[]): string;
|
|
2739
|
-
|
|
2740
|
-
interface ImageDimensions {
|
|
2741
|
-
width: number;
|
|
2742
|
-
height: number;
|
|
2743
|
-
}
|
|
2744
|
-
interface ImagePoint {
|
|
2745
|
-
x: number;
|
|
2746
|
-
y: number;
|
|
2747
|
-
}
|
|
2748
|
-
interface CropBox {
|
|
2749
|
-
x: number;
|
|
2750
|
-
y: number;
|
|
2751
|
-
width: number;
|
|
2752
|
-
height: number;
|
|
2753
|
-
}
|
|
2754
|
-
type AspectRatio = number | null;
|
|
2755
|
-
interface ImageTransform {
|
|
2756
|
-
rotate: number;
|
|
2757
|
-
flipH: boolean;
|
|
2758
|
-
flipV: boolean;
|
|
2759
|
-
}
|
|
2760
|
-
interface ImageAdjustments {
|
|
2761
|
-
brightness: number;
|
|
2762
|
-
contrast: number;
|
|
2763
|
-
saturation: number;
|
|
2764
|
-
exposure: number;
|
|
2765
|
-
temperature: number;
|
|
2766
|
-
/**
|
|
2767
|
-
* -100 (green) to 100 (magenta), 0 is default. White-balance tint correction in Duv × 3000
|
|
2768
|
-
* (process 2 only; the legacy process ignores it).
|
|
2769
|
-
*/
|
|
2770
|
-
tint?: number;
|
|
2771
|
-
blur: number;
|
|
2772
|
-
opacity: number;
|
|
2773
|
-
/**
|
|
2774
|
-
* Rendering process the values are interpreted by. `2` (the latest; new edits and Reset get
|
|
2775
|
-
* it): linear-light exposure, Bradford white balance, LUT tone curve without intermediate
|
|
2776
|
-
* clipping. `1` or missing: the legacy 8-bit rendering, so edits saved before process
|
|
2777
|
-
* versions existed look exactly as they did. See `normalizeProcessVersion`.
|
|
2778
|
-
*/
|
|
2779
|
-
process?: 1 | 2;
|
|
2780
|
-
/**
|
|
2781
|
-
* Non-destructive adjustment layers, evaluated bottom (first) to top (last) after the base
|
|
2782
|
-
* adjustments above, on the encoded sRGB result. Missing or empty: no layers (edits saved
|
|
2783
|
-
* before layers existed render exactly as before).
|
|
2784
|
-
*/
|
|
2785
|
-
layers?: AdjustmentLayer[];
|
|
2786
|
-
}
|
|
2787
|
-
type AdjustmentKind = 'curves' | 'levels' | 'hueSaturation' | 'vibrance' | 'colorBalance' | 'blackWhite' | 'invert' | 'posterize' | 'threshold' | 'photoFilter';
|
|
2788
|
-
/** A Curves point; `input` and `output` are levels, 0..255. */
|
|
2789
|
-
interface CurvePoint {
|
|
2790
|
-
input: number;
|
|
2791
|
-
output: number;
|
|
2792
|
-
}
|
|
2793
|
-
/** Curves: each channel's curve first, then the master (composite) curve, as in Photoshop. */
|
|
2794
|
-
interface CurvesParams {
|
|
2795
|
-
master: CurvePoint[];
|
|
2796
|
-
red: CurvePoint[];
|
|
2797
|
-
green: CurvePoint[];
|
|
2798
|
-
blue: CurvePoint[];
|
|
2799
|
-
}
|
|
2800
|
-
/** One Levels record. Black / white points are levels (0..255); `gamma` is the midtone slider (0.1..9.99). */
|
|
2801
|
-
interface LevelsChannel {
|
|
2802
|
-
inBlack: number;
|
|
2803
|
-
inWhite: number;
|
|
2804
|
-
gamma: number;
|
|
2805
|
-
outBlack: number;
|
|
2806
|
-
outWhite: number;
|
|
2807
|
-
}
|
|
2808
|
-
/** Levels: each channel's record first, then the master record, as in Photoshop. */
|
|
2809
|
-
interface LevelsParams {
|
|
2810
|
-
master: LevelsChannel;
|
|
2811
|
-
red: LevelsChannel;
|
|
2812
|
-
green: LevelsChannel;
|
|
2813
|
-
blue: LevelsChannel;
|
|
2814
|
-
}
|
|
2815
|
-
/** One of Hue/Saturation's six colour ranges (reds, yellows, greens, cyans, blues, magentas). */
|
|
2816
|
-
interface HueRange {
|
|
2817
|
-
/** Hue shift in degrees (-180..180). */
|
|
2818
|
-
hue: number;
|
|
2819
|
-
/** Saturation change in percent (-100..100). */
|
|
2820
|
-
saturation: number;
|
|
2821
|
-
/** Lightness change in percent (-100..100). */
|
|
2822
|
-
lightness: number;
|
|
2823
|
-
/** Hue degrees where the range starts fading in, is fully on, starts fading out and ends (may wrap). */
|
|
2824
|
-
bounds: [number, number, number, number];
|
|
2825
|
-
}
|
|
2826
|
-
interface HueSaturationParams {
|
|
2827
|
-
/** Master hue shift in degrees (-180..180), or the hue when colorizing (0..360). */
|
|
2828
|
-
hue: number;
|
|
2829
|
-
/** Percent, -100..100 (0..100 when colorizing). */
|
|
2830
|
-
saturation: number;
|
|
2831
|
-
/** Percent, -100..100. */
|
|
2832
|
-
lightness: number;
|
|
2833
|
-
colorize: boolean;
|
|
2834
|
-
/** Six ranges: reds, yellows, greens, cyans, blues, magentas. */
|
|
2835
|
-
ranges: HueRange[];
|
|
2836
|
-
}
|
|
2837
|
-
interface VibranceParams {
|
|
2838
|
-
/** -100..100 */
|
|
2839
|
-
vibrance: number;
|
|
2840
|
-
/** -100..100 */
|
|
2841
|
-
saturation: number;
|
|
2842
|
-
}
|
|
2843
|
-
/** Cyan–red, magenta–green, yellow–blue sliders, -100..100 each. */
|
|
2844
|
-
type ColorBalanceTone = [number, number, number];
|
|
2845
|
-
interface ColorBalanceParams {
|
|
2846
|
-
shadows: ColorBalanceTone;
|
|
2847
|
-
midtones: ColorBalanceTone;
|
|
2848
|
-
highlights: ColorBalanceTone;
|
|
2849
|
-
preserveLuminosity: boolean;
|
|
2850
|
-
}
|
|
2851
|
-
/** Black & White: percent weights of the six colours (Photoshop defaults 40 60 40 60 20 80). */
|
|
2852
|
-
interface BlackWhiteParams {
|
|
2853
|
-
reds: number;
|
|
2854
|
-
yellows: number;
|
|
2855
|
-
greens: number;
|
|
2856
|
-
cyans: number;
|
|
2857
|
-
blues: number;
|
|
2858
|
-
magentas: number;
|
|
2859
|
-
/** Tint colour (`#rrggbb`), applied like the Color blend mode, or `null` for none. */
|
|
2860
|
-
tint: string | null;
|
|
2861
|
-
}
|
|
2862
|
-
interface PhotoFilterParams {
|
|
2863
|
-
/** Filter colour, `#rrggbb`. */
|
|
2864
|
-
color: string;
|
|
2865
|
-
/** Percent, 0..100. */
|
|
2866
|
-
density: number;
|
|
2867
|
-
preserveLuminosity: boolean;
|
|
2868
|
-
}
|
|
2869
|
-
interface PosterizeParams {
|
|
2870
|
-
/** 2..255 */
|
|
2871
|
-
levels: number;
|
|
2872
|
-
}
|
|
2873
|
-
interface ThresholdParams {
|
|
2874
|
-
/** 1..255: luma at or above it becomes white. */
|
|
2875
|
-
level: number;
|
|
2876
|
-
}
|
|
2877
|
-
type InvertParams = Record<string, never>;
|
|
2878
|
-
interface AdjustmentParamsMap {
|
|
2879
|
-
curves: CurvesParams;
|
|
2880
|
-
levels: LevelsParams;
|
|
2881
|
-
hueSaturation: HueSaturationParams;
|
|
2882
|
-
vibrance: VibranceParams;
|
|
2883
|
-
colorBalance: ColorBalanceParams;
|
|
2884
|
-
blackWhite: BlackWhiteParams;
|
|
2885
|
-
invert: InvertParams;
|
|
2886
|
-
posterize: PosterizeParams;
|
|
2887
|
-
threshold: ThresholdParams;
|
|
2888
|
-
photoFilter: PhotoFilterParams;
|
|
2889
|
-
}
|
|
2890
|
-
interface AdjustmentLayerBase {
|
|
2891
|
-
id: string;
|
|
2892
|
-
/** Optional display name. */
|
|
2893
|
-
name?: string;
|
|
2894
|
-
enabled: boolean;
|
|
2895
|
-
/** 0..1 */
|
|
2896
|
-
opacity: number;
|
|
2897
|
-
/** How the adjusted colour is blended over the layers below. */
|
|
2898
|
-
blend: BlendMode;
|
|
2899
|
-
/**
|
|
2900
|
-
* Optional layer mask (natural image pixels): where it is 0 the layer has no effect. Missing:
|
|
2901
|
-
* the layer applies everywhere (layers saved before masks existed are unchanged).
|
|
2902
|
-
*/
|
|
2903
|
-
mask?: AdjustmentLayerMask;
|
|
2904
|
-
}
|
|
2905
|
-
/**
|
|
2906
|
-
* A layer mask: 8-bit coverage of the source image, run-length encoded (see
|
|
2907
|
-
* `encodeSelectionRle`), plus non-destructive density and feather.
|
|
2908
|
-
*/
|
|
2909
|
-
interface AdjustmentLayerMask {
|
|
2910
|
-
width: number;
|
|
2911
|
-
height: number;
|
|
2912
|
-
/** `r1:` run-length encoding of the mask bytes. */
|
|
2913
|
-
rle: string;
|
|
2914
|
-
/** 0..1 (missing = 1). */
|
|
2915
|
-
density?: number;
|
|
2916
|
-
/** Gaussian σ in pixels (missing = 0). */
|
|
2917
|
-
feather?: number;
|
|
2918
|
-
/** `false` keeps the mask but ignores it. */
|
|
2919
|
-
enabled?: boolean;
|
|
2920
|
-
}
|
|
2921
|
-
/** A non-destructive adjustment layer (Photoshop's Layer › New Adjustment Layer). */
|
|
2922
|
-
type AdjustmentLayer = {
|
|
2923
|
-
[K in AdjustmentKind]: AdjustmentLayerBase & {
|
|
2924
|
-
kind: K;
|
|
2925
|
-
params: AdjustmentParamsMap[K];
|
|
2926
|
-
};
|
|
2927
|
-
}[AdjustmentKind];
|
|
2928
|
-
type AdjustmentLayerOf<K extends AdjustmentKind> = Extract<AdjustmentLayer, {
|
|
2929
|
-
kind: K;
|
|
2930
|
-
}>;
|
|
2931
|
-
interface DepthMaskOptions {
|
|
2932
|
-
enabled: boolean;
|
|
2933
|
-
maskSource: string | null;
|
|
2934
|
-
mode: 'threshold' | 'brightness';
|
|
2935
|
-
depthRange: [number, number];
|
|
2936
|
-
softness: number;
|
|
2937
|
-
invert: boolean;
|
|
2938
|
-
}
|
|
2939
|
-
type AnnotationType = 'pen' | 'rect' | 'circle' | 'arrow' | 'line' | 'text' | 'image';
|
|
2940
|
-
interface BaseAnnotation {
|
|
2941
|
-
id: string;
|
|
2942
|
-
type: AnnotationType;
|
|
2943
|
-
x: number;
|
|
2944
|
-
y: number;
|
|
2945
|
-
rotation?: number;
|
|
2946
|
-
opacity?: number;
|
|
2947
|
-
/** Blend mode the annotation is drawn with (default `normal`). */
|
|
2948
|
-
blend?: BlendMode;
|
|
2949
|
-
}
|
|
2950
|
-
interface PenAnnotation extends BaseAnnotation {
|
|
2951
|
-
type: 'pen';
|
|
2952
|
-
points: ImagePoint[];
|
|
2953
|
-
strokeColor: string;
|
|
2954
|
-
strokeWidth: number;
|
|
2955
|
-
}
|
|
2956
|
-
interface RectAnnotation extends BaseAnnotation {
|
|
2957
|
-
type: 'rect';
|
|
2958
|
-
width: number;
|
|
2959
|
-
height: number;
|
|
2960
|
-
strokeColor: string;
|
|
2961
|
-
strokeWidth: number;
|
|
2962
|
-
fillColor?: string;
|
|
2963
|
-
cornerRadius?: number;
|
|
2964
|
-
}
|
|
2965
|
-
interface CircleAnnotation extends BaseAnnotation {
|
|
2966
|
-
type: 'circle';
|
|
2967
|
-
radiusX: number;
|
|
2968
|
-
radiusY: number;
|
|
2969
|
-
strokeColor: string;
|
|
2970
|
-
strokeWidth: number;
|
|
2971
|
-
fillColor?: string;
|
|
2972
|
-
}
|
|
2973
|
-
interface ArrowAnnotation extends BaseAnnotation {
|
|
2974
|
-
type: 'arrow';
|
|
2975
|
-
endX: number;
|
|
2976
|
-
endY: number;
|
|
2977
|
-
strokeColor: string;
|
|
2978
|
-
strokeWidth: number;
|
|
2979
|
-
}
|
|
2980
|
-
interface LineAnnotation extends BaseAnnotation {
|
|
2981
|
-
type: 'line';
|
|
2982
|
-
endX: number;
|
|
2983
|
-
endY: number;
|
|
2984
|
-
strokeColor: string;
|
|
2985
|
-
strokeWidth: number;
|
|
2986
|
-
}
|
|
2987
|
-
interface TextAnnotation extends BaseAnnotation {
|
|
2988
|
-
type: 'text';
|
|
2989
|
-
text: string;
|
|
2990
|
-
fontSize: number;
|
|
2991
|
-
fontFamily?: string;
|
|
2992
|
-
color: string;
|
|
2993
|
-
fontWeight?: string | number;
|
|
2994
|
-
}
|
|
2995
|
-
interface ImageAnnotation extends BaseAnnotation {
|
|
2996
|
-
type: 'image';
|
|
2997
|
-
src: string;
|
|
20
|
+
interface PlaneLayout {
|
|
21
|
+
planes: number;
|
|
2998
22
|
width: number;
|
|
2999
23
|
height: number;
|
|
24
|
+
depth: number;
|
|
25
|
+
/** PSB: RLE row counts are 4 bytes. */
|
|
26
|
+
psb: boolean;
|
|
3000
27
|
}
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
interface ImageEditorState {
|
|
3006
|
-
sourceUrl: string | null;
|
|
3007
|
-
/** Canvas (document) size in pixels: the source image's natural size. */
|
|
3008
|
-
imageDimensions: ImageDimensions;
|
|
3009
|
-
crop: CropBox | null;
|
|
3010
|
-
transform: ImageTransform;
|
|
3011
|
-
/**
|
|
3012
|
-
* Compatibility view of the layer stack: the develop filter of the active pixel layer (or the
|
|
3013
|
-
* Background), its blur (or `legacyOutputBlur`), the output opacity and every adjustment layer
|
|
3014
|
-
* in stack order. Edit it with `setAdjustments` and the adjustment-layer methods.
|
|
3015
|
-
*/
|
|
3016
|
-
adjustments: ImageAdjustments;
|
|
3017
|
-
/** Compatibility view: the parametric depth mask of the active pixel layer (or the Background). */
|
|
3018
|
-
depthMask: DepthMaskOptions;
|
|
3019
|
-
/** Compatibility view: the annotation of every annotation layer, bottom to top. */
|
|
3020
|
-
annotations: Annotation[];
|
|
3021
|
-
selectedAnnotationId: string | null;
|
|
3022
|
-
activeTool: ImageEditorTool;
|
|
3023
|
-
zoom: number;
|
|
3024
|
-
pan: ImagePoint;
|
|
3025
|
-
isOriginalCompared: boolean;
|
|
3026
|
-
/** Viewport fit mode: 'contain' scales to full viewport bounds; 'margin' scales to 85% with 1.0 cap (default). */
|
|
3027
|
-
fit?: ImageEditorFit;
|
|
3028
|
-
/**
|
|
3029
|
-
* The active selection (8-bit coverage over the source image), or null/missing when nothing is
|
|
3030
|
-
* selected. Recorded in undo history and saved as `selection` in `toJSON()`.
|
|
3031
|
-
*/
|
|
3032
|
-
selection?: SelectionMask | null;
|
|
3033
|
-
/** Quick Mask view: tint the unselected area instead of drawing marching ants (view state). */
|
|
3034
|
-
quickMask?: boolean;
|
|
3035
|
-
/**
|
|
3036
|
-
* The layer stack, bottom to top. Opening an image gives one pixel layer, "Background", whose
|
|
3037
|
-
* pixels are the source image. Layers are immutable: compare them by identity.
|
|
3038
|
-
*/
|
|
3039
|
-
layers: ImageLayer[];
|
|
3040
|
-
/** The layer that layer commands, painting and `setAdjustments` act on, or `null`. */
|
|
3041
|
-
activeLayerId: string | null;
|
|
3042
|
-
/** Whether painting targets the active layer's pixels or its mask. */
|
|
3043
|
-
activeTarget: LayerTarget;
|
|
3044
|
-
/** Export alpha (0..1), applied after compositing; `adjustments.opacity` mirrors it. */
|
|
3045
|
-
outputOpacity: number;
|
|
3046
|
-
/**
|
|
3047
|
-
* Blur that runs after the adjustment layers, kept from v1 / v2 documents that had both so
|
|
3048
|
-
* they render as before. New edits blur a layer instead (`blur` filter).
|
|
3049
|
-
*/
|
|
3050
|
-
legacyOutputBlur?: number;
|
|
3051
|
-
/** Brush settings and foreground / background colours of the paint tools (view state). */
|
|
3052
|
-
paint: PaintOptions;
|
|
3053
|
-
/**
|
|
3054
|
-
* The light layer effects use when they follow the global light (Photoshop's Global Light);
|
|
3055
|
-
* missing = angle 120°, altitude 30°. Recorded in undo history and saved in `toJSON()`.
|
|
3056
|
-
*/
|
|
3057
|
-
globalLight?: GlobalLight;
|
|
3058
|
-
/**
|
|
3059
|
-
* The document's patterns (from an opened PSD), which pattern effects use by id besides the
|
|
3060
|
-
* built-in ones. Recorded in undo history and saved in `toJSON()`.
|
|
3061
|
-
*/
|
|
3062
|
-
patterns?: EffectPattern[];
|
|
3063
|
-
/**
|
|
3064
|
-
* While a smart object's contents are open for editing (Edit Contents), the smart objects
|
|
3065
|
-
* being edited, outermost first: the state shows the contents as a document of their own until
|
|
3066
|
-
* `closeSmartObjectContents`. Missing when the document itself is shown.
|
|
3067
|
-
*/
|
|
3068
|
-
editingContents?: Array<{
|
|
3069
|
-
layerId: string;
|
|
3070
|
-
name: string;
|
|
3071
|
-
}>;
|
|
3072
|
-
}
|
|
3073
|
-
/**
|
|
3074
|
-
* A stored editor state in the document-level schema (versions 1 and 2). Documents whose layer
|
|
3075
|
-
* stack has exactly this shape are still written this way, byte for byte.
|
|
3076
|
-
*/
|
|
3077
|
-
interface LegacySerializedImageEditorState {
|
|
3078
|
-
/**
|
|
3079
|
-
* Schema version. `2` adds `adjustments.layers`; states without layers are still written as
|
|
3080
|
-
* `1` so they round-trip unchanged. See `migrateSerializedImageEditorState`.
|
|
3081
|
-
*/
|
|
3082
|
-
version: 1 | 2;
|
|
3083
|
-
crop: CropBox | null;
|
|
3084
|
-
transform: ImageTransform;
|
|
3085
|
-
adjustments: ImageAdjustments;
|
|
3086
|
-
depthMask: DepthMaskOptions;
|
|
3087
|
-
annotations: Annotation[];
|
|
3088
|
-
/** The active selection, run-length encoded. Missing when nothing is selected. */
|
|
3089
|
-
selection?: SerializedSelection;
|
|
3090
|
-
}
|
|
3091
|
-
/**
|
|
3092
|
-
* A stored editor state: the document-level schema (v1 / v2) or the layered schema (v3, see
|
|
3093
|
-
* `SerializedLayeredImageEditorState`). `toJSON()` writes v1 / v2 while the layer stack still
|
|
3094
|
-
* has the shape those versions describe.
|
|
3095
|
-
*/
|
|
3096
|
-
type SerializedImageEditorState = LegacySerializedImageEditorState | SerializedLayeredImageEditorState;
|
|
3097
|
-
interface ExportOptions {
|
|
3098
|
-
format?: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
3099
|
-
quality?: number;
|
|
3100
|
-
width?: number;
|
|
3101
|
-
height?: number;
|
|
3102
|
-
includeAnnotations?: boolean;
|
|
3103
|
-
/** Render only these layers (groups with their children). */
|
|
3104
|
-
layerIds?: string[];
|
|
3105
|
-
}
|
|
3106
|
-
interface ImageEditorOptions {
|
|
3107
|
-
image?: string | HTMLImageElement;
|
|
3108
|
-
initialState?: Partial<SerializedImageEditorState>;
|
|
3109
|
-
onStateChange?: (state: ImageEditorState) => void;
|
|
3110
|
-
maxHistoryDepth?: number;
|
|
3111
|
-
/**
|
|
3112
|
-
* Upper bound for the pixel data held only by undo / redo steps (tiles shared with the
|
|
3113
|
-
* current state are free). The oldest steps are dropped first. Default 512 MiB.
|
|
3114
|
-
*/
|
|
3115
|
-
maxHistoryBytes?: number;
|
|
3116
|
-
/** Viewport fit mode: 'contain' scales to full viewport bounds; 'margin' scales to 85% with 1.0 cap (default). */
|
|
3117
|
-
fit?: ImageEditorFit;
|
|
3118
|
-
}
|
|
3119
|
-
interface InpaintOptions {
|
|
3120
|
-
prompt: string;
|
|
3121
|
-
imageDataUrl: string;
|
|
3122
|
-
maskDataUrl?: string;
|
|
3123
|
-
cropBox?: CropBox | null;
|
|
3124
|
-
}
|
|
3125
|
-
interface RemoveBackgroundOptions {
|
|
3126
|
-
imageDataUrl: string;
|
|
3127
|
-
}
|
|
3128
|
-
type InpaintHook = (options: InpaintOptions) => Promise<string | void> | string | void;
|
|
3129
|
-
type RemoveBackgroundHook = (options: RemoveBackgroundOptions) => Promise<string | void> | string | void;
|
|
3130
|
-
interface ImageEditorAIHooks {
|
|
3131
|
-
onInpaint?: InpaintHook;
|
|
3132
|
-
onRemoveBackground?: RemoveBackgroundHook;
|
|
3133
|
-
}
|
|
28
|
+
/** Decodes planar channel data (`planes` planes of `height` rows each). */
|
|
29
|
+
declare function decodePlanes(compression: number, data: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
30
|
+
/** RLE-encodes planar data: row counts (u16, or u32 in PSB), then the packed rows. */
|
|
31
|
+
declare function encodeRle(decoded: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
3134
32
|
|
|
3135
33
|
/**
|
|
3136
34
|
* Applies color and tone adjustments (brightness, contrast, saturation, exposure, temperature, tint,
|
|
@@ -4485,30 +1383,13 @@ declare function writeAdjustmentBlock<K extends AdjustmentKind>(kind: K, params:
|
|
|
4485
1383
|
data: Uint8Array;
|
|
4486
1384
|
};
|
|
4487
1385
|
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
/** Pixels per inch (default 72). */
|
|
4496
|
-
resolution?: number;
|
|
4497
|
-
/** The document's patterns; those the effects use are embedded (built-in ones too). */
|
|
4498
|
-
patterns?: readonly EffectPattern[];
|
|
4499
|
-
/** Written as image resources 1037 and 1049. */
|
|
4500
|
-
globalLight?: GlobalLight;
|
|
4501
|
-
}
|
|
4502
|
-
interface PsdExportResult {
|
|
4503
|
-
bytes: Uint8Array;
|
|
4504
|
-
psb: boolean;
|
|
4505
|
-
/** Layer records written (group folders and dividers included). */
|
|
4506
|
-
records: number;
|
|
4507
|
-
/** One sentence per loss, naming the layers. */
|
|
4508
|
-
warnings: string[];
|
|
4509
|
-
}
|
|
4510
|
-
/** Writes the prepared stack as PSD (or PSB) bytes. */
|
|
4511
|
-
declare function exportPsd(input: PsdExportInput): PsdExportResult;
|
|
1386
|
+
/**
|
|
1387
|
+
* Layer effects ↔ PSD: the object-based effects descriptor (`lfx2`, `lfxs` on groups, `lmfx` with
|
|
1388
|
+
* several instances per kind) both ways, and the legacy `lrFX` block on read. Key names follow the
|
|
1389
|
+
* descriptors Photoshop writes (documented by reverse-engineering in psd-tools and ag-psd, MIT).
|
|
1390
|
+
*
|
|
1391
|
+
* Reading reports what it could not represent exactly (`notes`), so import warns only for that.
|
|
1392
|
+
*/
|
|
4512
1393
|
|
|
4513
1394
|
interface ParsedLayerEffects {
|
|
4514
1395
|
effects: LayerEffects;
|
|
@@ -4820,4 +1701,4 @@ declare class FreeTransformTool {
|
|
|
4820
1701
|
key(e: ShortcutEvent): boolean;
|
|
4821
1702
|
}
|
|
4822
1703
|
|
|
4823
|
-
export { ADJUSTMENT_KEYS, ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, type AIResultOptions, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerNode, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, AffineMatrix, type Annotation, type AnnotationLayer, type AnnotationPlacement, type AnnotationType, type ArrowAnnotation, type AspectRatio, BACKGROUND_LAYER_ID, BACKGROUND_LAYER_NAME, BLUR_FILTER_ID, BRUSH_OPTION_CONTROLS, type BaseAnnotation, type BlackWhiteParams, BlendMode, type BlurFilter, BrushSettings, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, CompositorOptions, type CompositorSources, type ControlSection, type ControlSpec, type ControlTrack, type ConvertOptions, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D50, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DEVELOP_FILTER_ID, type DepthMaskOptions, type DescValue, type Descriptor, type DeserializeContext, type DevelopFilter, type DevelopSettings, type DropZone, EMPTY_DISTANCE, type EffectControl, EffectPattern, type ExportOptions, FREE_TRANSFORM_CONTENTS, FREE_TRANSFORM_FIELDS, FREE_TRANSFORM_MODES, FREE_TRANSFORM_MODE_OPTIONS, type FillOptions, type FreeTransformBar, type FreeTransformContent, type FreeTransformField, type FreeTransformGeometry, type FreeTransformHost, type FreeTransformInit, type FreeTransformMode, type FreeTransformPreview, type FreeTransformResult, FreeTransformSession, FreeTransformTool, type FreeTransformToolOptions, GUIDED_FILTER_EPS, type GestureModifiers, GlobalLight, type GroupLayer, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HistoryEntryHandle, Homography, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, type ImageEditorAssetStore, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorFit, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImageLayer, type ImageLayerType, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, Interpolation, type InvertParams, LATEST_PROCESS_VERSION, LAYERED_SCHEMA_VERSION, LAYER_EFFECT_MENU, LEGACY_PROCESS_VERSION, LUMA_709, type LayerBase, type LayerBlendMode, LayerCompositor, LayerEffect, LayerEffectKind, type LayerEffectRow, LayerEffects, type LayerEffectsPanelModel, type LayerFilter, type LayerFilterKind, type LayerLocation, LayerLocks, type LayerMaskProps, type LayerMenuAction, type LayerMenuItem, LayerOperationError, type LayerPanelRow, type LayerPlacement, type LayerProperties, type LayerSourcesHost, type LayerStack, type LayerTarget, type LegacyParts, type LegacySerializedImageEditorState, type LegacyViewResult, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, MIXER_MIXING_OPTIONS, MIXER_OPTION_CONTROLS, type MagicWandOptions, type Matrix3, MixerLoad, MixerSettings, MixerStroke, type MixerStrokeInit, MixerTarget, type MosaicImageDataLike, type MosaicRegion, PAINT_TOOLS, PATTERN_BLOCK_KEYS, PSD_BLEND_KEYS, PSD_FILE_ACCEPT, PaintGesture, type PaintOptions, type PaintPointerSample, type PaintStrokeResult, PaintStrokeSession, type PaintTool, type ParsedAdjustment, type ParsedLayerEffects, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelLayer, type PixelLayerInit, type PixelOp, PixelSurface, type PlaneLayout, type PosterizeParams, type PsdChannel, PsdError, type PsdExportInput, type PsdExportResult, type PsdFile, type PsdHeader, type PsdImportOptions, type PsdImportResult, type PsdLayerMask, type PsdLayerRecord, type PsdLayerSummary, type PsdPattern, type PsdRect, type PsdResource, type PsdSmartFilter, type PsdTaggedBlock, type PsdTreeNode, Quad, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RasterMask, RasterRect, type RectAnnotation, type ReferenceItem, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type RouteInput, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, SMART_RENDER_MARGIN, SUPPORTED_ADJUSTMENT_KEYS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializeContext, type SerializedAdjustmentLayer, type SerializedAnnotationLayer, type SerializedGroupLayer, type SerializedImageEditorState, type SerializedLayer, type SerializedLayerEffects, type SerializedLayeredImageEditorState, type SerializedPattern, type SerializedPixelLayer, type SerializedRasterMask, type SerializedSelection, type SerializedSmartContents, type SerializedSmartFilter, type SerializedSmartObjectLayer, type ShapeSelectionOptions, type ShortcutEvent, type SmartCanvas, type SmartContents, type SmartDocument, type SmartFilter, type SmartFilterKind, type SmartFilterRow, type SmartFilterStack, type SmartObjectInfo, type SmartObjectLayer, type SmartPlacement, type SmartPsdData, type SmartRenderOptions, StrokeApply, StrokeCoverage, type StrokeInit, StrokePoint, type StrokeTool, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, TRANSFORM_ANCHORS, type TextAnnotation, type ThresholdParams, TiledSurface, type ToneRangePreset, type TransformAnchor, type TransformHandle, type TransformModifiers, type TransformOverlay, type TransformParams, type TransformReadout, type UnitLevels, VIBRANCE_GREY, Vec2, type VibranceParams, type ViewportMetrics, WARP_GRID_OPTIONS, WARP_STYLE_OPTIONS, type WarpBar, WarpMesh, WarpPreset, WarpStyle, XYZ_D50_TO_SRGB, activeAdjustmentLayers, activeSmartFilters, addLayerEffect, addLayerFilter, addSmartFilter, addToHistogram, adjustmentKindLabel, adjustmentLayersKey, adjustmentNodeAsLayer, adjustmentNodeFromLegacy, anchorPoint, annotationLayerFor, annotationLayerName, applyAdjustmentLayers, applyAdjustments, applyBoxBlur, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyOutputStage, applyParams, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, applySmartFilters, backgroundLayer, baseProjection, blackWhiteGray, blurFilter, borderCoverage, boxMean, boxPointOf, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contentsBox, contentsSurface, contractCoverage, controlPosition, controlTrackBackground, convertToSmartObject, copySmartObject, cornersFromMatrix, coverageToByte, coveringRect, createAdjustmentLayer, createImageCaptureSurface, createImageEditTools, createImageEditorToolProvider, createImageEffectTools, createImageLayerTools, createImagePaintTools, createImagePsdTools, createImageSelectionTools, createImageSmartObjectTools, createImageTransformTools, createSelectionMask, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerChannel, decodeLayerMask, decodeMergedImage, decodePlanes, decodePngDataUrl, decodeSelectionRle, defaultAdjustmentParams, depthMaskAlpha, depthRasterMask, describeLayer, describeLayerEffects, describeSelection, describeTransform, deserializeEffects, deserializeLayer, deserializeLayers, deserializePatterns, deserializeSelection, developFilter, developFromAdjustments, developTarget, distanceTransform, documentContents, downloadPsd, dropPlacement, dropZone, duplicateLayer, edgeWidth, effectControlChange, ellipsePoints, ellipseSelection, emptyHistogram, encodeRle, encodeSelectionRle, encodeSurface, evaluateAdjustmentLayers, expandCoverage, exportPsd, featherCoverage, filterMaskCoverage, findAdjustmentControl, findLayerControl, flipCorners, formatControlValue, fullSelection, geometryHomography, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, groupLayers, guidePlanes, guidedFilterColor, handlePaintShortcut, hasResampledLegacyMask, hasSurface, hasWarp, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, identityTransform, imageEditorStateMigrations, imageToCanvasPoint, importPsd, insertCurvePoint, instancesOf, invertMatrix3, invertSelection, isActiveFilter, isAdjustmentKind, isContentsDecoded, isDefaultDepthMask, isIdentityTransform, isLegacyShape, isPaintTool, isQuarterTurn, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSpatialFilter, isTransformAnchor, isValidWarp, kelvinToTemperature, layerBadge, layerEffectControls, layerEffectsBadge, layerEffectsOf, layerEffectsPanel, layerLabel, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, layerMenu, layerName, layerPanelRows, layerTree, layerTypeLabel, layersFromLegacy, legacyAdjustmentLayer, legacyMaskOf, legacyView, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, maskSummary, matrixFromCorners, matrixFromParams, migrateSerializedImageEditorState, migrateToLayeredState, mixerLoadResult, modifySelection, moveCurvePoint, moveLayer, moveSmartFilter, mulMatrix3, needsLegacyBase, neutralHueRange, newContentsId, newLayerId, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeFilter, normalizeLayerMask, normalizePlacement, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeSmartFilter, normalizeStoredAdjustments, offsetLayer, offsetSmartObject, openPsdFile, parseAdjustmentBlock, parseBlend, parseColor, parseLfx2, parseLrfx, parsePatternBlock, parseSelectionMode, parseVersionedDescriptor, photoFilterMatrix, pixelLayerBounds, pixelLayers, placeContents, placeLayer, placementAt, placementBounds, placementGeometry, pointerPressure, polygonCoverage, polygonSelection, posterizeValue, presetWarp, previewStep, projectImagePoint, projectImageRect, projectMaskCoverage, projectQuarterTurn, psdBytesFromBase64, psdFileName, psdPatternToEffectPattern, psdToLayers, quickMaskPixels, rangeLightness, rasterContents, rasterMaskFromLegacy, rasterizeSmartObject, readAdjustmentControls, readPsd, rectSelection, referencePoint, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, removeLayer, removeLayerEffect, removeLayerFilter, removeSmartFilter, renderLayeredBase, renderSmartObject, replaceContents, requireLayer, requireSmartObject, requireUnlocked, rerender, resizePixels, resizeSelection, resolveExternalAssets, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, rgbUnitToHex, runLayerFilters, runLayerMenuAction, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeContents, serializeEffects, serializeLayer, serializeLayers, serializeLayersExternal, serializePatterns, serializeSelection, setControlPath, setLayerEffects, setLayerEffectsEnabled, setLayerMask, setLayerProperties, setSmartFilterMask, setSmartFiltersEnabled, setSmartPlacement, shiftCoverage, smartFilterRows, smartObjectLayers, smoothCoverage, splitOverlayAnnotations, srgb8ToLab, srgbToLinear, sumHistograms, tempTintToXy, temperatureToKelvin, toHex, toneCurve, toneLuts, toneRange, transformHomography, transformMap, transformedBox, transformedPoint, ungroupLayer, unionRect, unprojectCanvasPoint, updateLayerEffect, updateLayerFilter, updateLayerMaskProps, updateSmartFilter, uvToXy, versionedDescriptorBytes, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, withFilterMaskSurface, withNewIds, writeAdjustmentBlock, writeLfx2, writePatternBlock, writePsd, xyToTempTint, xyToUv };
|
|
1704
|
+
export { ADJUSTMENT_KEYS, ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, AdjustmentKind, type AdjustmentKindInfo, AdjustmentLayer, AdjustmentLayerMask, AdjustmentLayerNode, AdjustmentLayerOf, AdjustmentParamsMap, Annotation, AnnotationLayer, BACKGROUND_LAYER_ID, BACKGROUND_LAYER_NAME, BLUR_FILTER_ID, BRUSH_OPTION_CONTROLS, BlendMode, type Chromaticity, ColorDistance, CompositorSources, type ControlSection, type ControlSpec, type ControlTrack, type ConvertOptions, CropBox, CurvePoint, D50, D65, DEFAULT_SELECTION_TOOL_OPTIONS, DEVELOP_FILTER_ID, DepthMaskOptions, type DescValue, type Descriptor, DevelopFilter, type DropZone, type EffectControl, EffectPattern, FREE_TRANSFORM_FIELDS, FREE_TRANSFORM_MODE_OPTIONS, type FreeTransformBar, type FreeTransformField, FreeTransformGeometry, FreeTransformInit, FreeTransformMode, FreeTransformResult, FreeTransformSession, FreeTransformTool, type FreeTransformToolOptions, type GestureModifiers, HUE_RANGE_LABELS, HueRange, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_STATE_VERSION, ImageAdjustments, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorToolProviderOptions, ImageHistogram, ImageLayer, ImagePoint, type ImageProcessVersion, ImageProjection, ImageTransform, Interpolation, LATEST_PROCESS_VERSION, LAYER_EFFECT_MENU, LEGACY_PROCESS_VERSION, LUMA_709, LayerCompositor, LayerEffect, LayerEffectKind, type LayerEffectRow, LayerEffects, type LayerEffectsPanelModel, LayerFilter, type LayerMenuAction, type LayerMenuItem, type LayerPanelRow, LayerPlacement, type LayerStack, type LegacyParts, type LegacyViewResult, LevelsChannel, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, MIXER_MIXING_OPTIONS, MIXER_OPTION_CONTROLS, type Matrix3, MixerLoad, MixerSettings, type MosaicImageDataLike, type MosaicRegion, PAINT_TOOLS, PATTERN_BLOCK_KEYS, PSD_FILE_ACCEPT, PaintGesture, type PaintPointerSample, type PaintTool, type ParsedAdjustment, type ParsedLayerEffects, PixelLayer, type PixelOp, PixelSurface, type PlaneLayout, PsdError, type PsdPattern, Quad, type QuickMaskStyle, REFINE_EDGE_CONTROLS, RasterMask, RasterRect, type ReferenceItem, type RefineEdgeControl, RefineEdgeParams, type RouteInput, SELECTION_MODE_LABELS, SELECTION_TOOLS, SMART_RENDER_MARGIN, SUPPORTED_ADJUSTMENT_KEYS, SelectionGesture, SelectionMask, SelectionMode, type SelectionToolKind, type SelectionToolOptions, SerializedImageEditorState, type ShortcutEvent, type SmartCanvas, SmartContents, SmartDocument, SmartFilter, type SmartFilterRow, SmartFilterStack, SmartObjectLayer, SmartPlacement, type SmartRenderOptions, TINT_SCALE, TONE_LUT_SIZE, TransformAnchor, type TransformHandle, type TransformModifiers, type TransformOverlay, type UnitLevels, VIBRANCE_GREY, Vec2, WARP_GRID_OPTIONS, WARP_STYLE_OPTIONS, type WarpBar, WarpMesh, WarpStyle, XYZ_D50_TO_SRGB, activeAdjustmentLayers, activeSmartFilters, addSmartFilter, addToHistogram, adjustmentKindLabel, adjustmentLayersKey, adjustmentNodeFromLegacy, annotationLayerFor, annotationLayerName, applyAdjustmentLayers, applyAdjustments, applyBoxBlur, applyDepthMask, applyLegacyAdjustments, applyMatrix3, applyOutputStage, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, applySmartFilters, backgroundLayer, baseProjection, blackWhiteGray, boxToCurvePoint, bradfordAdaptation, buildToneLut, clampControlValue, colorBalanceChannel, compileAdjustmentLayer, contentsBox, contentsSurface, controlPosition, controlTrackBackground, convertToSmartObject, copySmartObject, coveringRect, createAdjustmentLayer, createImageCaptureSurface, createImageEditTools, createImageEditorToolProvider, createImageEffectTools, createImageLayerTools, createImagePaintTools, createImagePsdTools, createImageSelectionTools, createImageSmartObjectTools, createImageTransformTools, curveLutFromLevels, curvePointToBox, curveSvgPath, decodePlanes, defaultAdjustmentParams, depthRasterMask, describeLayer, describeLayerEffects, describeSelection, developFromAdjustments, developTarget, documentContents, downloadPsd, dropPlacement, dropZone, effectControlChange, emptyHistogram, encodeRle, evaluateAdjustmentLayers, filterMaskCoverage, findAdjustmentControl, findLayerControl, formatControlValue, getControlPath, handlePaintShortcut, hasResampledLegacyMask, hexToRgb, hitTestCurvePoint, hslToRgb, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, insertCurvePoint, instancesOf, invertMatrix3, isAdjustmentKind, isContentsDecoded, isDefaultDepthMask, isLegacyShape, isPaintTool, isQuarterTurn, kelvinToTemperature, layerBadge, layerEffectControls, layerEffectsBadge, layerEffectsPanel, layerLabel, layerMenu, layerPanelRows, layersFromLegacy, legacyAdjustmentLayer, legacyMaskOf, legacyView, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, maskSummary, mixerLoadResult, moveCurvePoint, moveSmartFilter, mulMatrix3, needsLegacyBase, neutralHueRange, newContentsId, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizePlacement, normalizeProcessVersion, normalizeSmartFilter, offsetSmartObject, openPsdFile, parseAdjustmentBlock, parseLfx2, parseLrfx, parsePatternBlock, parseVersionedDescriptor, photoFilterMatrix, placeContents, placementAt, placementBounds, placementGeometry, pointerPressure, posterizeValue, projectQuarterTurn, psdBytesFromBase64, psdFileName, psdPatternToEffectPattern, quickMaskPixels, rangeLightness, rasterContents, rasterMaskFromLegacy, rasterizeSmartObject, readAdjustmentControls, removeAlpha, removeCurvePoint, removeSmartFilter, renderLayeredBase, renderSmartObject, replaceContents, requireSmartObject, rerender, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, rgbUnitToHex, runLayerMenuAction, sampleLut, sampleToneLut, selectionModeFromModifiers, selectionOutline, setControlPath, setSmartFilterMask, setSmartFiltersEnabled, setSmartPlacement, smartFilterRows, splitOverlayAnnotations, srgbToLinear, sumHistograms, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, updateSmartFilter, uvToXy, versionedDescriptorBytes, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, withFilterMaskSurface, writeAdjustmentBlock, writeLfx2, writePatternBlock, xyToTempTint, xyToUv };
|