@pixerate/editor 0.80.0 → 0.82.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/README.md +13 -3
- package/dist/agent/index.cjs +138 -13
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +9 -5
- package/dist/agent/index.d.ts +9 -5
- package/dist/agent/index.js +144 -19
- package/dist/agent/index.js.map +1 -1
- package/dist/animation-editor/index.d.cts +1 -1
- package/dist/animation-editor/index.d.ts +1 -1
- package/dist/bridge/index.d.cts +3 -3
- package/dist/bridge/index.d.ts +3 -3
- package/dist/{bridge-client-C5dRjrz5.d.ts → bridge-client-CMGfnjTl.d.ts} +1 -1
- package/dist/{bridge-client-C5OziCRK.d.cts → bridge-client-VpnICVxP.d.cts} +1 -1
- package/dist/{builtins-BKYlHH1s.d.ts → builtins-CV1fDj64.d.ts} +5 -1
- package/dist/{builtins-1kqwLUnb.d.cts → builtins-c4w0eAYl.d.cts} +5 -1
- package/dist/canvas/index.cjs +235 -104
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +59 -1
- package/dist/canvas/index.d.ts +59 -1
- package/dist/canvas/index.js +234 -103
- package/dist/canvas/index.js.map +1 -1
- package/dist/capture-DFEMFmVt.d.cts +133 -0
- package/dist/capture-wwNGaW05.d.ts +133 -0
- package/dist/chart/index.d.cts +1 -1
- package/dist/chart/index.d.ts +1 -1
- package/dist/{chunk-2CJ3LPYQ.js → chunk-424H3P4I.js} +13 -295
- package/dist/chunk-424H3P4I.js.map +1 -0
- package/dist/{chunk-K73CKYUM.cjs → chunk-EI2MOVQ3.cjs} +198 -3
- package/dist/chunk-EI2MOVQ3.cjs.map +1 -0
- package/dist/chunk-FURT6ZFZ.cjs +1 -0
- package/dist/chunk-FURT6ZFZ.cjs.map +1 -0
- package/dist/{chunk-GPWNYQ7R.js → chunk-O2W2SP3C.js} +197 -2
- package/dist/chunk-O2W2SP3C.js.map +1 -0
- package/dist/{chunk-UN33YOXW.cjs → chunk-PA5S7KPC.cjs} +293 -2
- package/dist/chunk-PA5S7KPC.cjs.map +1 -0
- package/dist/{chunk-IB3ZHQAX.js → chunk-PTYWCFFW.js} +29 -4
- package/dist/chunk-PTYWCFFW.js.map +1 -0
- package/dist/{chunk-JQ3BB3E6.js → chunk-PXDEFEG2.js} +293 -2
- package/dist/chunk-PXDEFEG2.js.map +1 -0
- package/dist/chunk-REOJJIY3.js +201 -0
- package/dist/chunk-REOJJIY3.js.map +1 -0
- package/dist/chunk-RJ2BFKEN.js +1 -0
- package/dist/chunk-RJ2BFKEN.js.map +1 -0
- package/dist/{chunk-YU4WQE5M.cjs → chunk-TAPXWP2B.cjs} +95 -377
- package/dist/chunk-TAPXWP2B.cjs.map +1 -0
- package/dist/{chunk-HXDMZQTD.cjs → chunk-TPOT575P.cjs} +29 -4
- package/dist/{chunk-IB3ZHQAX.js.map → chunk-TPOT575P.cjs.map} +1 -1
- package/dist/chunk-VJUVNERT.cjs +201 -0
- package/dist/chunk-VJUVNERT.cjs.map +1 -0
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +2 -2
- package/dist/commands/index.d.ts +2 -2
- package/dist/commands/index.js +1 -1
- package/dist/diagram/index.d.cts +1 -1
- package/dist/diagram/index.d.ts +1 -1
- package/dist/dom-capture-7Wvf6Tyg.d.ts +59 -0
- package/dist/dom-capture-GyYuE-zq.d.cts +59 -0
- package/dist/generation/index.cjs +932 -791
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +268 -242
- package/dist/generation/index.d.ts +268 -242
- package/dist/generation/index.js +926 -785
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +362 -2
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +35 -2
- package/dist/image-editor/index.d.ts +35 -2
- package/dist/image-editor/index.js +361 -1
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -16
- package/dist/{registry-DIpIaCkH.d.cts → registry-BqA1AZt0.d.cts} +1 -1
- package/dist/{registry-7AZFuand.d.ts → registry-D-4fit9C.d.ts} +1 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +16 -16
- package/dist/tools/index.cjs +33 -4
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +4 -2
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js +43 -14
- package/dist/video-editor/index.d.cts +1 -1
- package/dist/video-editor/index.d.ts +1 -1
- package/package.json +2 -1
- package/skills/README.md +55 -0
- package/skills/pixerate-agent-tools/SKILL.md +75 -0
- package/skills/pixerate-animation-editor/SKILL.md +155 -0
- package/skills/pixerate-animation-editor/references/commands.md +123 -0
- package/skills/pixerate-canvas/SKILL.md +231 -0
- package/skills/pixerate-chart/SKILL.md +190 -0
- package/skills/pixerate-diagram/SKILL.md +134 -0
- package/skills/pixerate-generation/SKILL.md +109 -0
- package/skills/pixerate-image-editor/SKILL.md +140 -0
- package/skills/pixerate-parameters/SKILL.md +83 -0
- package/skills/pixerate-rich-text/SKILL.md +160 -0
- package/skills/pixerate-spreadsheet/SKILL.md +146 -0
- package/skills/pixerate-vector/SKILL.md +191 -0
- package/skills/pixerate-vector/references/commands.md +138 -0
- package/skills/pixerate-video-editor/SKILL.md +173 -0
- package/dist/chunk-2CJ3LPYQ.js.map +0 -1
- package/dist/chunk-GPWNYQ7R.js.map +0 -1
- package/dist/chunk-HXDMZQTD.cjs.map +0 -1
- package/dist/chunk-JQ3BB3E6.js.map +0 -1
- package/dist/chunk-K73CKYUM.cjs.map +0 -1
- package/dist/chunk-UN33YOXW.cjs.map +0 -1
- package/dist/chunk-YU4WQE5M.cjs.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { b as LoadReport, J as JsonObject, f as MigrationStep } from '../migrate-iTlm3a8h.cjs';
|
|
2
|
-
import {
|
|
2
|
+
import { a as AgentToolProvider, A as AgentTool } from '../registry-BqA1AZt0.cjs';
|
|
3
|
+
import { b as CaptureSurface } from '../capture-DFEMFmVt.cjs';
|
|
3
4
|
import '../schema-Di0CS6Pe.cjs';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -1330,6 +1331,16 @@ declare class ImageEditorController {
|
|
|
1330
1331
|
setComparing(comparing: boolean): void;
|
|
1331
1332
|
render(targetCanvas: HTMLCanvasElement, options?: RenderOptions): Promise<void>;
|
|
1332
1333
|
renderExport(options?: ExportOptions): Promise<HTMLCanvasElement>;
|
|
1334
|
+
/**
|
|
1335
|
+
* Renders the edited image (adjustments, layers and, by default, annotations) in the
|
|
1336
|
+
* source image's own orientation and frame, ignoring crop, rotation and flips, so it lines
|
|
1337
|
+
* up with natural-pixel coordinates (selections, `select_region`). `scale` ≤ 1 shrinks it.
|
|
1338
|
+
* Returns `null` when no image is loaded.
|
|
1339
|
+
*/
|
|
1340
|
+
renderSourceView(options?: {
|
|
1341
|
+
scale?: number;
|
|
1342
|
+
includeAnnotations?: boolean;
|
|
1343
|
+
}): Promise<HTMLCanvasElement | null>;
|
|
1333
1344
|
toDataURL(options?: ExportOptions): Promise<string>;
|
|
1334
1345
|
toBlob(options?: ExportOptions): Promise<Blob>;
|
|
1335
1346
|
renderMask(options?: {
|
|
@@ -1638,8 +1649,13 @@ interface ImageEditorToolProviderOptions {
|
|
|
1638
1649
|
* control ranges and the applied values are echoed.
|
|
1639
1650
|
* - `add_adjustment_layer {kind, params?, opacity?, blend?, name?}`.
|
|
1640
1651
|
* - `render_preview {maxSide}`: the rendered image as a PNG, longest side at most `maxSide`.
|
|
1652
|
+
* - `capture_view {region, rect?, ...}`: a screenshot of the whole image, the selection or a rect in
|
|
1653
|
+
* natural pixels (up to 8× for close inspection), optionally with the selection shaded.
|
|
1641
1654
|
* - Selections and masks: `get_selection`, `select_region`, `select_by_color`, `modify_selection`,
|
|
1642
1655
|
* `refine_selection`, `apply_selection_as_mask` (see `createImageSelectionTools`).
|
|
1656
|
+
* - Layers, geometry and history: `get_image_info`, `get_histogram`, `update_adjustment_layer`,
|
|
1657
|
+
* `remove_adjustment_layer`, `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`,
|
|
1658
|
+
* `flip_image`, `undo_image`, `redo_image` (see `createImageEditTools`).
|
|
1643
1659
|
*/
|
|
1644
1660
|
declare function createImageEditorToolProvider(controller: ImageEditorController, options?: ImageEditorToolProviderOptions): AgentToolProvider;
|
|
1645
1661
|
|
|
@@ -1768,6 +1784,14 @@ declare class SelectionGesture {
|
|
|
1768
1784
|
*/
|
|
1769
1785
|
declare function createImageSelectionTools(controller: ImageEditorController): AgentTool[];
|
|
1770
1786
|
|
|
1787
|
+
/**
|
|
1788
|
+
* Agent tools for the image editor's layers, geometry and history: `get_image_info`,
|
|
1789
|
+
* `get_histogram`, `update_adjustment_layer`, `remove_adjustment_layer`,
|
|
1790
|
+
* `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`, `flip_image`,
|
|
1791
|
+
* `undo_image` and `redo_image`. Each write is one undo step and returns what changed.
|
|
1792
|
+
*/
|
|
1793
|
+
declare function createImageEditTools(controller: ImageEditorController): AgentTool[];
|
|
1794
|
+
|
|
1771
1795
|
/**
|
|
1772
1796
|
* Region-based mosaic (pixelation) and box-blur filters for redacting or anonymizing
|
|
1773
1797
|
* rectangular bounding boxes on an ImageData-like buffer.
|
|
@@ -1809,4 +1833,13 @@ declare function applyRegionMosaic<T extends MosaicImageDataLike>(imageData: T,
|
|
|
1809
1833
|
*/
|
|
1810
1834
|
declare function applyRegionBlur<T extends MosaicImageDataLike>(imageData: T, regions: MosaicRegion[], radius?: number): T;
|
|
1811
1835
|
|
|
1812
|
-
|
|
1836
|
+
/**
|
|
1837
|
+
* The image editor as a capture surface. Units are natural pixels of the source image,
|
|
1838
|
+
* the same space as `get_selection` and `select_region`: crop, rotation and flips are not
|
|
1839
|
+
* applied (use `render_preview` for the final framing), adjustments, layers and annotations
|
|
1840
|
+
* are. Regions: the whole image, the selection's bounds, or a rect. Small regions are
|
|
1841
|
+
* enlarged up to 8× with hard pixel edges for close inspection.
|
|
1842
|
+
*/
|
|
1843
|
+
declare function createImageCaptureSurface(controller: ImageEditorController): CaptureSurface;
|
|
1844
|
+
|
|
1845
|
+
export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, 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, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageCaptureSurface, createImageEditTools, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { b as LoadReport, J as JsonObject, f as MigrationStep } from '../migrate-iTlm3a8h.js';
|
|
2
|
-
import {
|
|
2
|
+
import { a as AgentToolProvider, A as AgentTool } from '../registry-D-4fit9C.js';
|
|
3
|
+
import { b as CaptureSurface } from '../capture-wwNGaW05.js';
|
|
3
4
|
import '../schema-Di0CS6Pe.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -1330,6 +1331,16 @@ declare class ImageEditorController {
|
|
|
1330
1331
|
setComparing(comparing: boolean): void;
|
|
1331
1332
|
render(targetCanvas: HTMLCanvasElement, options?: RenderOptions): Promise<void>;
|
|
1332
1333
|
renderExport(options?: ExportOptions): Promise<HTMLCanvasElement>;
|
|
1334
|
+
/**
|
|
1335
|
+
* Renders the edited image (adjustments, layers and, by default, annotations) in the
|
|
1336
|
+
* source image's own orientation and frame, ignoring crop, rotation and flips, so it lines
|
|
1337
|
+
* up with natural-pixel coordinates (selections, `select_region`). `scale` ≤ 1 shrinks it.
|
|
1338
|
+
* Returns `null` when no image is loaded.
|
|
1339
|
+
*/
|
|
1340
|
+
renderSourceView(options?: {
|
|
1341
|
+
scale?: number;
|
|
1342
|
+
includeAnnotations?: boolean;
|
|
1343
|
+
}): Promise<HTMLCanvasElement | null>;
|
|
1333
1344
|
toDataURL(options?: ExportOptions): Promise<string>;
|
|
1334
1345
|
toBlob(options?: ExportOptions): Promise<Blob>;
|
|
1335
1346
|
renderMask(options?: {
|
|
@@ -1638,8 +1649,13 @@ interface ImageEditorToolProviderOptions {
|
|
|
1638
1649
|
* control ranges and the applied values are echoed.
|
|
1639
1650
|
* - `add_adjustment_layer {kind, params?, opacity?, blend?, name?}`.
|
|
1640
1651
|
* - `render_preview {maxSide}`: the rendered image as a PNG, longest side at most `maxSide`.
|
|
1652
|
+
* - `capture_view {region, rect?, ...}`: a screenshot of the whole image, the selection or a rect in
|
|
1653
|
+
* natural pixels (up to 8× for close inspection), optionally with the selection shaded.
|
|
1641
1654
|
* - Selections and masks: `get_selection`, `select_region`, `select_by_color`, `modify_selection`,
|
|
1642
1655
|
* `refine_selection`, `apply_selection_as_mask` (see `createImageSelectionTools`).
|
|
1656
|
+
* - Layers, geometry and history: `get_image_info`, `get_histogram`, `update_adjustment_layer`,
|
|
1657
|
+
* `remove_adjustment_layer`, `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`,
|
|
1658
|
+
* `flip_image`, `undo_image`, `redo_image` (see `createImageEditTools`).
|
|
1643
1659
|
*/
|
|
1644
1660
|
declare function createImageEditorToolProvider(controller: ImageEditorController, options?: ImageEditorToolProviderOptions): AgentToolProvider;
|
|
1645
1661
|
|
|
@@ -1768,6 +1784,14 @@ declare class SelectionGesture {
|
|
|
1768
1784
|
*/
|
|
1769
1785
|
declare function createImageSelectionTools(controller: ImageEditorController): AgentTool[];
|
|
1770
1786
|
|
|
1787
|
+
/**
|
|
1788
|
+
* Agent tools for the image editor's layers, geometry and history: `get_image_info`,
|
|
1789
|
+
* `get_histogram`, `update_adjustment_layer`, `remove_adjustment_layer`,
|
|
1790
|
+
* `move_adjustment_layer`, `set_crop`, `reset_crop`, `set_rotation`, `flip_image`,
|
|
1791
|
+
* `undo_image` and `redo_image`. Each write is one undo step and returns what changed.
|
|
1792
|
+
*/
|
|
1793
|
+
declare function createImageEditTools(controller: ImageEditorController): AgentTool[];
|
|
1794
|
+
|
|
1771
1795
|
/**
|
|
1772
1796
|
* Region-based mosaic (pixelation) and box-blur filters for redacting or anonymizing
|
|
1773
1797
|
* rectangular bounding boxes on an ImageData-like buffer.
|
|
@@ -1809,4 +1833,13 @@ declare function applyRegionMosaic<T extends MosaicImageDataLike>(imageData: T,
|
|
|
1809
1833
|
*/
|
|
1810
1834
|
declare function applyRegionBlur<T extends MosaicImageDataLike>(imageData: T, regions: MosaicRegion[], radius?: number): T;
|
|
1811
1835
|
|
|
1812
|
-
|
|
1836
|
+
/**
|
|
1837
|
+
* The image editor as a capture surface. Units are natural pixels of the source image,
|
|
1838
|
+
* the same space as `get_selection` and `select_region`: crop, rotation and flips are not
|
|
1839
|
+
* applied (use `render_preview` for the final framing), adjustments, layers and annotations
|
|
1840
|
+
* are. Regions: the whole image, the selection's bounds, or a rect. Small regions are
|
|
1841
|
+
* enlarged up to 8× with hard pixel edges for close inspection.
|
|
1842
|
+
*/
|
|
1843
|
+
declare function createImageCaptureSurface(controller: ImageEditorController): CaptureSurface;
|
|
1844
|
+
|
|
1845
|
+
export { ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationType, type ArrowAnnotation, type AspectRatio, BLEND_MODES, type BaseAnnotation, type BlackWhiteParams, type BlendMode, type BlendModeInfo, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DIRECT_GAUSSIAN_MAX_SIGMA, type DepthMaskOptions, EMPTY_DISTANCE, type ExportOptions, GUIDED_FILTER_EPS, type GestureModifiers, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, 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, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerMaskProps, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelOp, type PosterizeParams, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RectAnnotation, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type Rgb$1 as Rgb, type Rgba, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializedImageEditorState, type SerializedSelection, type ShapeSelectionOptions, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, activeAdjustmentLayers, adjustmentKindLabel, adjustmentLayersKey, applyAdjustmentLayers, applyAdjustments, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, blackWhiteGray, blendChannel, blendImageData, blendLum, blendPixel, blendRgb, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasCompositeOperation, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, createAdjustmentLayer, createImageCaptureSurface, createImageEditTools, createImageEditorToolProvider, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerMask, decodeSelectionRle, defaultAdjustmentParams, describeSelection, deserializeSelection, distanceTransform, edgeWidth, ellipsePoints, ellipseSelection, encodeSelectionRle, evaluateAdjustmentLayers, expandCoverage, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, gaussianBlur, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, guidePlanes, guidedFilterColor, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, insertCurvePoint, invertMatrix3, invertSelection, isAdjustmentKind, isBlendMode, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSeparableBlendMode, kelvinToTemperature, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, migrateSerializedImageEditorState, modifySelection, moveCurvePoint, mulMatrix3, neutralHueRange, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeBlendMode, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, parseSelectionMode, photoFilterMatrix, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, quickMaskPixels, rangeLightness, readAdjustmentControls, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, resizeSelection, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeSelection, setControlPath, setLum, shiftCoverage, smoothCoverage, srgb8ToLab, srgbToLinear, tempTintToXy, temperatureToKelvin, toneCurve, toneLuts, toneRange, unprojectCanvasPoint, updateLayerMaskProps, uvToXy, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, xyToTempTint, xyToUv };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCaptureTool
|
|
3
|
+
} from "../chunk-REOJJIY3.js";
|
|
1
4
|
import {
|
|
2
5
|
loadDocument
|
|
3
6
|
} from "../chunk-U5HZSFCS.js";
|
|
@@ -4610,6 +4613,27 @@ var ImageEditorController = class {
|
|
|
4610
4613
|
}
|
|
4611
4614
|
return this.renderer.renderExport(source, this.state, options);
|
|
4612
4615
|
}
|
|
4616
|
+
/**
|
|
4617
|
+
* Renders the edited image (adjustments, layers and, by default, annotations) in the
|
|
4618
|
+
* source image's own orientation and frame, ignoring crop, rotation and flips, so it lines
|
|
4619
|
+
* up with natural-pixel coordinates (selections, `select_region`). `scale` ≤ 1 shrinks it.
|
|
4620
|
+
* Returns `null` when no image is loaded.
|
|
4621
|
+
*/
|
|
4622
|
+
async renderSourceView(options = {}) {
|
|
4623
|
+
const source = this.imageElement || this.state.sourceUrl;
|
|
4624
|
+
if (!source) return null;
|
|
4625
|
+
const { width, height } = this.state.imageDimensions;
|
|
4626
|
+
const k = Math.min(1, Math.max(0, options.scale ?? 1));
|
|
4627
|
+
return this.renderer.renderExport(
|
|
4628
|
+
source,
|
|
4629
|
+
{ ...this.state, crop: null, transform: { rotate: 0, flipH: false, flipV: false } },
|
|
4630
|
+
{
|
|
4631
|
+
width: Math.max(1, Math.round(width * k)),
|
|
4632
|
+
height: Math.max(1, Math.round(height * k)),
|
|
4633
|
+
includeAnnotations: options.includeAnnotations
|
|
4634
|
+
}
|
|
4635
|
+
);
|
|
4636
|
+
}
|
|
4613
4637
|
async toDataURL(options = {}) {
|
|
4614
4638
|
const canvas = await this.renderExport(options);
|
|
4615
4639
|
const format = options.format || "image/png";
|
|
@@ -5357,6 +5381,331 @@ function createImageSelectionTools(controller) {
|
|
|
5357
5381
|
return [getSelection, selectRegion, selectByColor, modify, refine, applyMask];
|
|
5358
5382
|
}
|
|
5359
5383
|
|
|
5384
|
+
// src/image-editor/capture.ts
|
|
5385
|
+
var NO_CANVAS = "Rendering is not available in this environment.";
|
|
5386
|
+
function selectionShade(selection, doc) {
|
|
5387
|
+
const canvas = doc.createElement("canvas");
|
|
5388
|
+
canvas.width = selection.width;
|
|
5389
|
+
canvas.height = selection.height;
|
|
5390
|
+
const context = canvas.getContext("2d");
|
|
5391
|
+
if (!context) return null;
|
|
5392
|
+
const pixels = context.createImageData(selection.width, selection.height);
|
|
5393
|
+
for (let i = 0; i < selection.data.length; i++) {
|
|
5394
|
+
pixels.data[i * 4 + 3] = Math.round(150 * (1 - selection.data[i] / 255));
|
|
5395
|
+
}
|
|
5396
|
+
context.putImageData(pixels, 0, 0);
|
|
5397
|
+
return canvas;
|
|
5398
|
+
}
|
|
5399
|
+
async function renderImageRegion(controller, request) {
|
|
5400
|
+
const state = controller.getState();
|
|
5401
|
+
const k = Math.min(1, request.scale);
|
|
5402
|
+
const view = await controller.renderSourceView({ scale: k });
|
|
5403
|
+
if (!view) throw new Error("No image is loaded, so there is nothing to capture.");
|
|
5404
|
+
if (typeof document === "undefined") throw new Error(NO_CANVAS);
|
|
5405
|
+
const out = document.createElement("canvas");
|
|
5406
|
+
out.width = request.width;
|
|
5407
|
+
out.height = request.height;
|
|
5408
|
+
const context = out.getContext("2d");
|
|
5409
|
+
if (!context) throw new Error(NO_CANVAS);
|
|
5410
|
+
const { rect } = request;
|
|
5411
|
+
context.imageSmoothingEnabled = request.scale < 1;
|
|
5412
|
+
if (request.format === "jpeg") {
|
|
5413
|
+
context.fillStyle = "#ffffff";
|
|
5414
|
+
context.fillRect(0, 0, out.width, out.height);
|
|
5415
|
+
}
|
|
5416
|
+
const kx = view.width / state.imageDimensions.width;
|
|
5417
|
+
const ky = view.height / state.imageDimensions.height;
|
|
5418
|
+
context.drawImage(view, rect.x * kx, rect.y * ky, rect.width * kx, rect.height * ky, 0, 0, out.width, out.height);
|
|
5419
|
+
if (request.includeOverlays) {
|
|
5420
|
+
const s = request.scale;
|
|
5421
|
+
const selection = state.selection;
|
|
5422
|
+
if (selection?.bounds && selection.width === state.imageDimensions.width && selection.height === state.imageDimensions.height) {
|
|
5423
|
+
const shade = selectionShade(selection, document);
|
|
5424
|
+
if (shade) context.drawImage(shade, rect.x, rect.y, rect.width, rect.height, 0, 0, out.width, out.height);
|
|
5425
|
+
}
|
|
5426
|
+
if (state.crop) {
|
|
5427
|
+
context.save();
|
|
5428
|
+
context.strokeStyle = "#ffd400";
|
|
5429
|
+
context.lineWidth = 2;
|
|
5430
|
+
context.setLineDash([6, 4]);
|
|
5431
|
+
context.strokeRect((state.crop.x - rect.x) * s, (state.crop.y - rect.y) * s, state.crop.width * s, state.crop.height * s);
|
|
5432
|
+
context.restore();
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
const url = out.toDataURL(request.format === "jpeg" ? "image/jpeg" : "image/png", request.quality);
|
|
5436
|
+
if (!url.startsWith("data:image/") || url.indexOf(",") === url.length - 1) throw new Error(NO_CANVAS);
|
|
5437
|
+
return url;
|
|
5438
|
+
}
|
|
5439
|
+
function createImageCaptureSurface(controller) {
|
|
5440
|
+
const whole = () => {
|
|
5441
|
+
const { width, height } = controller.getState().imageDimensions;
|
|
5442
|
+
return width > 0 && height > 0 ? { x: 0, y: 0, width, height } : null;
|
|
5443
|
+
};
|
|
5444
|
+
return {
|
|
5445
|
+
units: "image pixels",
|
|
5446
|
+
content: whole,
|
|
5447
|
+
selection: () => ({ rect: controller.getState().selection?.bounds ?? null }),
|
|
5448
|
+
overlays: "a shade over unselected pixels and the crop box outline",
|
|
5449
|
+
maxScale: 8,
|
|
5450
|
+
render: (request) => renderImageRegion(controller, request)
|
|
5451
|
+
};
|
|
5452
|
+
}
|
|
5453
|
+
|
|
5454
|
+
// src/image-editor/edit-tools.ts
|
|
5455
|
+
var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
5456
|
+
var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
|
|
5457
|
+
var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
|
|
5458
|
+
var LAYER_ID = { type: "string", description: 'Adjustment layer id from get_adjustments (e.g. "adj_1").' };
|
|
5459
|
+
var round = (n, digits = 2) => Math.round(n * 10 ** digits) / 10 ** digits;
|
|
5460
|
+
function binStats(bins, samples) {
|
|
5461
|
+
if (!samples) return { mean: null, p1: null, p99: null };
|
|
5462
|
+
let sum = 0;
|
|
5463
|
+
let seen = 0;
|
|
5464
|
+
let p1 = null;
|
|
5465
|
+
let p99 = null;
|
|
5466
|
+
for (let i = 0; i < bins.length; i++) {
|
|
5467
|
+
sum += i * bins[i];
|
|
5468
|
+
seen += bins[i];
|
|
5469
|
+
if (p1 === null && seen >= samples * 0.01) p1 = i;
|
|
5470
|
+
if (p99 === null && seen >= samples * 0.99) p99 = i;
|
|
5471
|
+
}
|
|
5472
|
+
return { mean: round(sum / samples, 1), p1, p99 };
|
|
5473
|
+
}
|
|
5474
|
+
function rebin(bins, count) {
|
|
5475
|
+
const out = new Array(count).fill(0);
|
|
5476
|
+
const width = bins.length / count;
|
|
5477
|
+
for (let i = 0; i < bins.length; i++) out[Math.floor(i / width)] += bins[i];
|
|
5478
|
+
return out;
|
|
5479
|
+
}
|
|
5480
|
+
function histogramSummary(h, bins) {
|
|
5481
|
+
const pct = (n) => h.samples ? round(n / h.samples * 100) : 0;
|
|
5482
|
+
const channels = { red: h.red, green: h.green, blue: h.blue, luminance: h.luminance };
|
|
5483
|
+
return {
|
|
5484
|
+
samples: h.samples,
|
|
5485
|
+
transparent: h.transparent,
|
|
5486
|
+
clipping: {
|
|
5487
|
+
shadowsPercent: { red: pct(h.shadows[0]), green: pct(h.shadows[1]), blue: pct(h.shadows[2]) },
|
|
5488
|
+
highlightsPercent: { red: pct(h.highlights[0]), green: pct(h.highlights[1]), blue: pct(h.highlights[2]) }
|
|
5489
|
+
},
|
|
5490
|
+
stats: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, binStats(v, h.samples)])),
|
|
5491
|
+
...bins ? { bins: Object.fromEntries(Object.entries(channels).map(([k, v]) => [k, rebin(v, bins)])) } : {}
|
|
5492
|
+
};
|
|
5493
|
+
}
|
|
5494
|
+
function createImageEditTools(controller) {
|
|
5495
|
+
const layerOrThrow = (id) => {
|
|
5496
|
+
const layers = controller.getAdjustmentLayers();
|
|
5497
|
+
const index = layers.findIndex((l) => l.id === id);
|
|
5498
|
+
if (index === -1) {
|
|
5499
|
+
const ids = layers.map((l) => l.id);
|
|
5500
|
+
throw new Error(`Unknown adjustment layer "${id}". ${ids.length ? `Layers: ${ids.join(", ")}.` : "There are no adjustment layers."}`);
|
|
5501
|
+
}
|
|
5502
|
+
return { layer: layers[index], index };
|
|
5503
|
+
};
|
|
5504
|
+
const layerJson = (id) => JSON.parse(JSON.stringify(controller.getAdjustmentLayer(id)));
|
|
5505
|
+
const geometry = () => {
|
|
5506
|
+
const s = controller.getState();
|
|
5507
|
+
const region = s.crop ?? { x: 0, y: 0, ...s.imageDimensions };
|
|
5508
|
+
const out = getRotatedSize(region.width, region.height, s.transform);
|
|
5509
|
+
return {
|
|
5510
|
+
image: { ...s.imageDimensions },
|
|
5511
|
+
crop: s.crop ? { ...s.crop } : null,
|
|
5512
|
+
rotation: normalizeAngle(s.transform.rotate),
|
|
5513
|
+
flipH: s.transform.flipH,
|
|
5514
|
+
flipV: s.transform.flipV,
|
|
5515
|
+
output: { width: Math.round(out.width), height: Math.round(out.height) }
|
|
5516
|
+
};
|
|
5517
|
+
};
|
|
5518
|
+
const history = () => ({ canUndo: controller.canUndo, canRedo: controller.canRedo });
|
|
5519
|
+
const requireImage = () => {
|
|
5520
|
+
const { width, height } = controller.getState().imageDimensions;
|
|
5521
|
+
if (!width || !height) throw new Error("No image is loaded. Ask the user to open one first.");
|
|
5522
|
+
return { width, height };
|
|
5523
|
+
};
|
|
5524
|
+
const getImageInfo = {
|
|
5525
|
+
name: "get_image_info",
|
|
5526
|
+
title: "Read image geometry",
|
|
5527
|
+
description: "Returns the source image size in pixels, the crop box (natural image pixels, or null for the whole image), rotation in degrees, flips, the output size after crop and rotation, the number of adjustment layers and whether undo / redo are available.",
|
|
5528
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5529
|
+
annotations: { title: "Read image geometry", ...READ },
|
|
5530
|
+
handler: () => ({ ...geometry(), layers: controller.getAdjustmentLayers().length, ...history() })
|
|
5531
|
+
};
|
|
5532
|
+
const getHistogram = {
|
|
5533
|
+
name: "get_histogram",
|
|
5534
|
+
title: "Read the histogram",
|
|
5535
|
+
description: "Returns the histogram of the last rendered preview (after adjustments and layers): per channel and luminance mean and 1st / 99th percentiles (0-255), and the percentage of pixels clipped to pure black or white per channel. Use it to judge exposure and clipping numerically. Pass bins for the counts themselves. Fails before the first render: call render_preview first.",
|
|
5536
|
+
inputSchema: {
|
|
5537
|
+
type: "object",
|
|
5538
|
+
properties: {
|
|
5539
|
+
bins: { type: "integer", enum: [16, 32, 64, 256], description: "Also return the counts in this many buckets per channel (default: no counts)." }
|
|
5540
|
+
},
|
|
5541
|
+
additionalProperties: false
|
|
5542
|
+
},
|
|
5543
|
+
annotations: { title: "Read the histogram", ...READ },
|
|
5544
|
+
handler: ({ bins }) => {
|
|
5545
|
+
const h = controller.getHistogram();
|
|
5546
|
+
if (!h) throw new Error("No histogram yet: it comes from the rendered preview. Call render_preview, then try again.");
|
|
5547
|
+
return histogramSummary(h, bins);
|
|
5548
|
+
}
|
|
5549
|
+
};
|
|
5550
|
+
const updateLayer = {
|
|
5551
|
+
name: "update_adjustment_layer",
|
|
5552
|
+
title: "Change an adjustment layer",
|
|
5553
|
+
description: 'Shows or hides a layer, renames it, or changes its blend mode or opacity, as one undo step. Change its parameters with set_adjustments ("layers.<id>.<control>"). Returns the updated layer.',
|
|
5554
|
+
inputSchema: {
|
|
5555
|
+
type: "object",
|
|
5556
|
+
properties: {
|
|
5557
|
+
layer: LAYER_ID,
|
|
5558
|
+
enabled: { type: "boolean", description: "false hides the layer without deleting it." },
|
|
5559
|
+
blend: { type: "string", enum: BLEND_MODES.map((m) => m.id), description: "Blend mode (see list_controls)." },
|
|
5560
|
+
opacity: { type: "number", minimum: 0, maximum: 1, description: "Layer opacity 0-1." },
|
|
5561
|
+
name: { type: "string", description: "Layer name shown in the layers panel." }
|
|
5562
|
+
},
|
|
5563
|
+
required: ["layer"],
|
|
5564
|
+
additionalProperties: false
|
|
5565
|
+
},
|
|
5566
|
+
annotations: { title: "Change an adjustment layer", ...WRITE_IDEMPOTENT },
|
|
5567
|
+
handler: ({ layer, enabled, blend, opacity, name }) => {
|
|
5568
|
+
layerOrThrow(layer);
|
|
5569
|
+
if (enabled === void 0 && blend === void 0 && opacity === void 0 && name === void 0) {
|
|
5570
|
+
throw new Error("Nothing to change. Pass enabled, blend, opacity or name.");
|
|
5571
|
+
}
|
|
5572
|
+
if (blend !== void 0 && !isBlendMode(blend)) throw new Error(`Unknown blend mode "${blend}".`);
|
|
5573
|
+
controller.updateAdjustmentLayer(layer, { enabled, blend, opacity, name });
|
|
5574
|
+
return { layer: layerJson(layer) };
|
|
5575
|
+
}
|
|
5576
|
+
};
|
|
5577
|
+
const removeLayer = {
|
|
5578
|
+
name: "remove_adjustment_layer",
|
|
5579
|
+
title: "Delete an adjustment layer",
|
|
5580
|
+
description: "Deletes an adjustment layer and its mask as one undo step. To hide it instead, use update_adjustment_layer with enabled false. Returns the remaining layer ids, bottom to top.",
|
|
5581
|
+
inputSchema: { type: "object", properties: { layer: LAYER_ID }, required: ["layer"], additionalProperties: false },
|
|
5582
|
+
annotations: { title: "Delete an adjustment layer", readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
5583
|
+
handler: ({ layer }) => {
|
|
5584
|
+
layerOrThrow(layer);
|
|
5585
|
+
controller.removeAdjustmentLayer(layer);
|
|
5586
|
+
return { removed: layer, layers: controller.getAdjustmentLayers().map((l) => l.id) };
|
|
5587
|
+
}
|
|
5588
|
+
};
|
|
5589
|
+
const moveLayer = {
|
|
5590
|
+
name: "move_adjustment_layer",
|
|
5591
|
+
title: "Reorder an adjustment layer",
|
|
5592
|
+
description: "Moves an adjustment layer to a position in the stack (0 = bottom, applied first) as one undo step. Layers apply bottom to top, so order changes the result. Returns the layer ids, bottom to top.",
|
|
5593
|
+
inputSchema: {
|
|
5594
|
+
type: "object",
|
|
5595
|
+
properties: {
|
|
5596
|
+
layer: LAYER_ID,
|
|
5597
|
+
to: { type: "integer", minimum: 0, description: "New index, 0 = bottom; past the top means the top." }
|
|
5598
|
+
},
|
|
5599
|
+
required: ["layer", "to"],
|
|
5600
|
+
additionalProperties: false
|
|
5601
|
+
},
|
|
5602
|
+
annotations: { title: "Reorder an adjustment layer", ...WRITE_IDEMPOTENT },
|
|
5603
|
+
handler: ({ layer, to }) => {
|
|
5604
|
+
const { index } = layerOrThrow(layer);
|
|
5605
|
+
const top = controller.getAdjustmentLayers().length - 1;
|
|
5606
|
+
const target = Math.min(to, top);
|
|
5607
|
+
if (target === index) throw new Error(`Layer "${layer}" is already at index ${index} (0 = bottom, ${top} = top).`);
|
|
5608
|
+
controller.moveAdjustmentLayer(layer, target);
|
|
5609
|
+
return { layer, index: target, layers: controller.getAdjustmentLayers().map((l) => l.id) };
|
|
5610
|
+
}
|
|
5611
|
+
};
|
|
5612
|
+
const setCrop = {
|
|
5613
|
+
name: "set_crop",
|
|
5614
|
+
title: "Crop the image",
|
|
5615
|
+
description: "Sets the crop box in natural image pixels of the un-rotated source (origin top-left; see get_image_info for the size) as one undo step. Non-destructive: reset_crop restores the whole image. Returns the new geometry and output size.",
|
|
5616
|
+
inputSchema: {
|
|
5617
|
+
type: "object",
|
|
5618
|
+
properties: {
|
|
5619
|
+
x: { type: "number", minimum: 0, description: "Left edge in source pixels." },
|
|
5620
|
+
y: { type: "number", minimum: 0, description: "Top edge in source pixels." },
|
|
5621
|
+
width: { type: "number", exclusiveMinimum: 0, description: "Width in source pixels." },
|
|
5622
|
+
height: { type: "number", exclusiveMinimum: 0, description: "Height in source pixels." }
|
|
5623
|
+
},
|
|
5624
|
+
required: ["x", "y", "width", "height"],
|
|
5625
|
+
additionalProperties: false
|
|
5626
|
+
},
|
|
5627
|
+
annotations: { title: "Crop the image", ...WRITE_IDEMPOTENT },
|
|
5628
|
+
handler: ({ x, y, width, height }) => {
|
|
5629
|
+
const image = requireImage();
|
|
5630
|
+
if (x + width > image.width + 0.5 || y + height > image.height + 0.5) {
|
|
5631
|
+
throw new Error(`The crop box (${x}, ${y}, ${width} \xD7 ${height}) goes outside the ${image.width} \xD7 ${image.height} image.`);
|
|
5632
|
+
}
|
|
5633
|
+
controller.setCrop({ x: Math.round(x), y: Math.round(y), width: Math.round(width), height: Math.round(height) });
|
|
5634
|
+
return geometry();
|
|
5635
|
+
}
|
|
5636
|
+
};
|
|
5637
|
+
const resetCrop = {
|
|
5638
|
+
name: "reset_crop",
|
|
5639
|
+
title: "Remove the crop",
|
|
5640
|
+
description: "Removes the crop so the whole image shows again, as one undo step. Returns the new geometry.",
|
|
5641
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5642
|
+
annotations: { title: "Remove the crop", ...WRITE_IDEMPOTENT },
|
|
5643
|
+
handler: () => {
|
|
5644
|
+
if (!controller.getState().crop) throw new Error("The image is not cropped.");
|
|
5645
|
+
controller.resetCrop();
|
|
5646
|
+
return geometry();
|
|
5647
|
+
}
|
|
5648
|
+
};
|
|
5649
|
+
const setRotation = {
|
|
5650
|
+
name: "set_rotation",
|
|
5651
|
+
title: "Rotate the image",
|
|
5652
|
+
description: "Sets the image rotation in degrees clockwise, as one undo step. Quarter turns (90, 180, 270) keep every pixel; other angles straighten the image inside a larger frame with transparent corners, so crop afterwards. Returns the new geometry.",
|
|
5653
|
+
inputSchema: {
|
|
5654
|
+
type: "object",
|
|
5655
|
+
properties: { degrees: { type: "number", minimum: -360, maximum: 360, description: "Absolute rotation in degrees clockwise (0 = upright)." } },
|
|
5656
|
+
required: ["degrees"],
|
|
5657
|
+
additionalProperties: false
|
|
5658
|
+
},
|
|
5659
|
+
annotations: { title: "Rotate the image", ...WRITE_IDEMPOTENT },
|
|
5660
|
+
handler: ({ degrees }) => {
|
|
5661
|
+
requireImage();
|
|
5662
|
+
controller.setRotation(degrees);
|
|
5663
|
+
return geometry();
|
|
5664
|
+
}
|
|
5665
|
+
};
|
|
5666
|
+
const flipImage = {
|
|
5667
|
+
name: "flip_image",
|
|
5668
|
+
title: "Flip the image",
|
|
5669
|
+
description: "Mirrors the image horizontally (left-right) or vertically (top-bottom), as one undo step. Flipping twice restores it. Returns the new geometry.",
|
|
5670
|
+
inputSchema: {
|
|
5671
|
+
type: "object",
|
|
5672
|
+
properties: { axis: { type: "string", enum: ["horizontal", "vertical"], description: "horizontal mirrors left-right; vertical mirrors top-bottom." } },
|
|
5673
|
+
required: ["axis"],
|
|
5674
|
+
additionalProperties: false
|
|
5675
|
+
},
|
|
5676
|
+
annotations: { title: "Flip the image", ...WRITE },
|
|
5677
|
+
handler: ({ axis }) => {
|
|
5678
|
+
requireImage();
|
|
5679
|
+
if (axis === "horizontal") controller.flipHorizontal();
|
|
5680
|
+
else controller.flipVertical();
|
|
5681
|
+
return geometry();
|
|
5682
|
+
}
|
|
5683
|
+
};
|
|
5684
|
+
const undo = {
|
|
5685
|
+
name: "undo_image",
|
|
5686
|
+
title: "Undo an image edit",
|
|
5687
|
+
description: "Undoes the last image edit (one tool call is one step). Returns whether undo and redo are still available.",
|
|
5688
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5689
|
+
annotations: { title: "Undo an image edit", ...WRITE },
|
|
5690
|
+
handler: () => {
|
|
5691
|
+
if (!controller.undo()) throw new Error("Nothing to undo.");
|
|
5692
|
+
return history();
|
|
5693
|
+
}
|
|
5694
|
+
};
|
|
5695
|
+
const redo = {
|
|
5696
|
+
name: "redo_image",
|
|
5697
|
+
title: "Redo an image edit",
|
|
5698
|
+
description: "Redoes the last undone image edit. Returns whether undo and redo are still available.",
|
|
5699
|
+
inputSchema: { type: "object", properties: {}, additionalProperties: false },
|
|
5700
|
+
annotations: { title: "Redo an image edit", ...WRITE },
|
|
5701
|
+
handler: () => {
|
|
5702
|
+
if (!controller.redo()) throw new Error("Nothing to redo.");
|
|
5703
|
+
return history();
|
|
5704
|
+
}
|
|
5705
|
+
};
|
|
5706
|
+
return [getImageInfo, getHistogram, updateLayer, removeLayer, moveLayer, setCrop, resetCrop, setRotation, flipImage, undo, redo];
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5360
5709
|
// src/image-editor/tools.ts
|
|
5361
5710
|
var LAYER_PATH = /^layers\.([^.]+)\.(.+)$/;
|
|
5362
5711
|
function adjustmentsSummary(adjustments) {
|
|
@@ -5574,7 +5923,16 @@ function createImageEditorToolProvider(controller, options = {}) {
|
|
|
5574
5923
|
return {
|
|
5575
5924
|
id: options.id ?? "image-editor",
|
|
5576
5925
|
namespace: options.namespace,
|
|
5577
|
-
tools: [
|
|
5926
|
+
tools: [
|
|
5927
|
+
getAdjustments,
|
|
5928
|
+
listControls,
|
|
5929
|
+
setAdjustments,
|
|
5930
|
+
addLayer,
|
|
5931
|
+
renderPreview,
|
|
5932
|
+
createCaptureTool(createImageCaptureSurface(controller), { subject: "the image (source orientation, before crop and rotation)", defaultPadding: 0 }),
|
|
5933
|
+
...createImageSelectionTools(controller),
|
|
5934
|
+
...createImageEditTools(controller)
|
|
5935
|
+
]
|
|
5578
5936
|
};
|
|
5579
5937
|
}
|
|
5580
5938
|
|
|
@@ -5950,6 +6308,8 @@ export {
|
|
|
5950
6308
|
controlTrackBackground,
|
|
5951
6309
|
coverageToByte,
|
|
5952
6310
|
createAdjustmentLayer,
|
|
6311
|
+
createImageCaptureSurface,
|
|
6312
|
+
createImageEditTools,
|
|
5953
6313
|
createImageEditorToolProvider,
|
|
5954
6314
|
createImageSelectionTools,
|
|
5955
6315
|
createSelectionMask,
|