@bensitu/image-editor 1.2.2 → 1.3.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 +7 -3
- package/dist/image-editor.esm.js +534 -207
- package/dist/image-editor.esm.js.map +2 -2
- package/dist/image-editor.esm.min.js +3 -3
- package/dist/image-editor.esm.min.js.map +3 -3
- package/dist/image-editor.esm.min.mjs +3 -3
- package/dist/image-editor.esm.min.mjs.map +3 -3
- package/dist/image-editor.esm.mjs +534 -207
- package/dist/image-editor.esm.mjs.map +2 -2
- package/dist/image-editor.js +534 -207
- package/dist/image-editor.js.map +2 -2
- package/dist/image-editor.min.js +2 -2
- package/dist/image-editor.min.js.map +3 -3
- package/image-editor.d.ts +21 -11
- package/package.json +1 -1
- package/src/image-editor.js +724 -287
package/README.md
CHANGED
|
@@ -126,12 +126,13 @@ When creating the editor instance, you can pass an options object to override de
|
|
|
126
126
|
| `scaleStep` | `0.05` | Scale step for zoom buttons |
|
|
127
127
|
| `rotationStep` | `90` | Default rotation step in degrees |
|
|
128
128
|
| `expandCanvasToImage` | `true` | Expand canvas to image size on load |
|
|
129
|
-
| `fitImageToCanvas` | `false` | Fit image to
|
|
129
|
+
| `fitImageToCanvas` | `false` | Fit image to the visible canvas viewport |
|
|
130
130
|
| `coverImageToCanvas` | `false` | Fit image to cover canvas (at least one side fits, allowing overflow). |
|
|
131
131
|
| `downsampleOnLoad` | `true` | Downsample large images before rendering |
|
|
132
132
|
| `downsampleMaxWidth` | `4000` | Max width count before downsampling |
|
|
133
133
|
| `downsampleMaxHeight` | `3000` | Max height count before downsampling |
|
|
134
134
|
| `downsampleQuality` | `0.92` | JPEG quality when downsampling |
|
|
135
|
+
| `imageLoadTimeoutMs` | `30000` | Timeout for image decode operations |
|
|
135
136
|
| `exportMultiplier` | `1` | Scale factor for export |
|
|
136
137
|
| `exportImageAreaByDefault` | `true` | Export only the image area (clipped to masks) |
|
|
137
138
|
| `defaultMaskWidth` | `50` | Default mask width (px) |
|
|
@@ -140,17 +141,20 @@ When creating the editor instance, you can pass an options object to override de
|
|
|
140
141
|
| `maskLabelOnSelect` | `true` | Show label when mask is selected |
|
|
141
142
|
| `maskLabelOffset` | `3` | Offset for mask labels from top-left corner |
|
|
142
143
|
| `maskName` | `mask` | Prefix for mask names/labels |
|
|
144
|
+
| `label.getText` | `(mask) => mask.maskName` | Callback for custom label text. The second argument is the mask's stable zero-based creation index (`mask.maskId - 1`). |
|
|
143
145
|
| `showPlaceholder` | `true` | Shows placeholder when no image is loaded |
|
|
144
146
|
| `initialImageBase64` | `null` | Base64 string to auto-load as initial image |
|
|
145
147
|
| `defaultDownloadFileName` | `edited_image.jpg` | Default file name for downloads |
|
|
146
148
|
| `crop.preserveMasksAfterCrop` | `false` | Keep masks that intersect the crop area, shifted into the cropped canvas. Merge masks first if they should be baked into the image pixels. |
|
|
147
149
|
|
|
150
|
+
`expandCanvasToImage`, `fitImageToCanvas`, and `coverImageToCanvas` are mutually exclusive layout modes. If more than one is enabled, the editor reports a warning and uses the first active mode in its existing load order.
|
|
151
|
+
|
|
148
152
|
## API Methods
|
|
149
153
|
|
|
150
154
|
| Method | Description |
|
|
151
155
|
|--------|-------------|
|
|
152
156
|
| `init(idMap)` | Bind the editor to DOM elements. Pass IDs in an object (optional). |
|
|
153
|
-
| `loadImage(imageBase64)` | Load an image from a base64 data string. Resolves after the Fabric image is on the canvas. |
|
|
157
|
+
| `loadImage(imageBase64, options)` | Load an image from a base64 data string. Resolves after the Fabric image is on the canvas. |
|
|
154
158
|
| `scaleImage(factor)` | Scale image to the given factor (relative to base scale). |
|
|
155
159
|
| `rotateImage(degrees)` | Rotate image to the given angle in degrees. |
|
|
156
160
|
| `resetImageTransform()` | Reset scale to 1 and rotation to 0. |
|
|
@@ -167,7 +171,7 @@ When creating the editor instance, you can pass an options object to override de
|
|
|
167
171
|
| `exportImageBase64(options)` | Export an image data URL. `fileType` can be `jpeg`, `png`, or `webp`. |
|
|
168
172
|
| `exportImageFile(options)` | Exports the current canvas (with or without masks) as a `File` object. `fileType` is exported directly when supported. |
|
|
169
173
|
|
|
170
|
-
Deprecated aliases are still available for compatibility
|
|
174
|
+
Deprecated aliases are still available for compatibility and will be removed in `v2.0.0`: `reset()`, `addMask(config)`, `merge()`, and `getImageBase64(options)`.
|
|
171
175
|
|
|
172
176
|
By default, applying crop removes unmerged masks. Set `crop.preserveMasksAfterCrop` to keep intersecting masks, or use `mergeMasks()` before cropping when masks should become part of the image pixels.
|
|
173
177
|
|