@gradio/imageeditor 0.3.2 → 0.4.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @gradio/imageeditor
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#7183](https://github.com/gradio-app/gradio/pull/7183) [`49d9c48`](https://github.com/gradio-app/gradio/commit/49d9c48537aa706bf72628e3640389470138bdc6) - [WIP] Refactor file normalization to be in the backend and remove it from the frontend of each component. Thanks [@abidlabs](https://github.com/abidlabs)!
|
|
8
|
+
|
|
3
9
|
## 0.3.2
|
|
4
10
|
|
|
5
11
|
### Fixes
|
|
@@ -50,10 +50,7 @@
|
|
|
50
50
|
/>
|
|
51
51
|
|
|
52
52
|
<Story
|
|
53
|
-
name="Image Editor Interactions"
|
|
54
|
-
parameters={{
|
|
55
|
-
diffThreshold: 0.1
|
|
56
|
-
}}
|
|
53
|
+
name="Image Editor Drawing Interactions"
|
|
57
54
|
args={{
|
|
58
55
|
value: {
|
|
59
56
|
path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
@@ -199,7 +196,56 @@
|
|
|
199
196
|
|
|
200
197
|
userEvent.click(canvas.getByLabelText("Add Layer"));
|
|
201
198
|
|
|
202
|
-
await userEvent.click(canvas.getByLabelText("
|
|
199
|
+
await userEvent.click(canvas.getByLabelText("Clear canvas"));
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
202
|
+
|
|
203
|
+
<Story
|
|
204
|
+
name="Image Editor Undo/Redo Interactions"
|
|
205
|
+
args={{
|
|
206
|
+
value: {
|
|
207
|
+
path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
208
|
+
url: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
209
|
+
orig_name: "cheetah.jpg"
|
|
210
|
+
},
|
|
211
|
+
type: "pil",
|
|
212
|
+
sources: ["upload", "webcam"],
|
|
213
|
+
interactive: "true",
|
|
214
|
+
brush: {
|
|
215
|
+
default_size: "auto",
|
|
216
|
+
colors: ["#ff0000", "#00ff00", "#0000ff"],
|
|
217
|
+
default_color: "#ff0000",
|
|
218
|
+
color_mode: "defaults"
|
|
219
|
+
},
|
|
220
|
+
eraser: {
|
|
221
|
+
default_size: "auto"
|
|
222
|
+
}
|
|
223
|
+
}}
|
|
224
|
+
play={async ({ canvasElement }) => {
|
|
225
|
+
const canvas = within(canvasElement);
|
|
226
|
+
|
|
227
|
+
const drawButton = canvas.getAllByLabelText("Draw button")[0];
|
|
228
|
+
|
|
229
|
+
userEvent.click(drawButton);
|
|
230
|
+
|
|
231
|
+
const drawCanvas = document.getElementsByTagName("canvas")[0];
|
|
232
|
+
if (!drawCanvas) {
|
|
233
|
+
throw new Error("Could not find canvas");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
237
|
+
|
|
238
|
+
await userEvent.pointer({
|
|
239
|
+
keys: "[MouseLeft][MouseRight]",
|
|
240
|
+
target: drawCanvas,
|
|
241
|
+
coords: { clientX: 300, clientY: 100 }
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
await userEvent.pointer({
|
|
245
|
+
keys: "[MouseLeft][MouseRight]",
|
|
246
|
+
target: drawCanvas,
|
|
247
|
+
coords: { clientX: 400, clientY: 200 }
|
|
248
|
+
});
|
|
203
249
|
|
|
204
250
|
await userEvent.click(canvas.getByLabelText("Undo"));
|
|
205
251
|
|
package/Index.svelte
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
import { Block } from "@gradio/atoms";
|
|
14
14
|
import { StatusTracker } from "@gradio/statustracker";
|
|
15
15
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
16
|
-
import { normalise_file } from "@gradio/client";
|
|
17
16
|
|
|
18
17
|
export let elem_id = "";
|
|
19
18
|
export let elem_classes: string[] = [];
|
|
@@ -42,7 +41,6 @@
|
|
|
42
41
|
"clipboard",
|
|
43
42
|
"webcam"
|
|
44
43
|
];
|
|
45
|
-
export let proxy_url: string;
|
|
46
44
|
export let interactive: boolean;
|
|
47
45
|
|
|
48
46
|
export let brush: Brush;
|
|
@@ -120,7 +118,7 @@
|
|
|
120
118
|
on:select={({ detail }) => gradio.dispatch("select", detail)}
|
|
121
119
|
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
|
122
120
|
on:error={({ detail }) => gradio.dispatch("error", detail)}
|
|
123
|
-
value={
|
|
121
|
+
value={value?.composite || null}
|
|
124
122
|
{label}
|
|
125
123
|
{show_label}
|
|
126
124
|
{show_download_button}
|
|
@@ -174,7 +172,6 @@
|
|
|
174
172
|
on:error
|
|
175
173
|
{brush}
|
|
176
174
|
{eraser}
|
|
177
|
-
{proxy_url}
|
|
178
175
|
changeable={attached_events.includes("change")}
|
|
179
176
|
i18n={gradio.i18n}
|
|
180
177
|
{transforms}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/imageeditor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"@types/tinycolor2": "^1.4.6",
|
|
11
11
|
"pixi.js": "^7.3.2",
|
|
12
12
|
"tinycolor2": "^1.6.0",
|
|
13
|
-
"@gradio/
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/image": "^0.8.0",
|
|
13
|
+
"@gradio/client": "^0.12.0",
|
|
14
|
+
"@gradio/image": "^0.9.0",
|
|
16
15
|
"@gradio/icons": "^0.3.2",
|
|
17
|
-
"@gradio/
|
|
18
|
-
"@gradio/upload": "^0.7.
|
|
16
|
+
"@gradio/atoms": "^0.5.1",
|
|
17
|
+
"@gradio/upload": "^0.7.2",
|
|
19
18
|
"@gradio/utils": "^0.2.2",
|
|
20
|
-
"@gradio/wasm": "^0.6.0"
|
|
19
|
+
"@gradio/wasm": "^0.6.0",
|
|
20
|
+
"@gradio/statustracker": "^0.4.5"
|
|
21
21
|
},
|
|
22
22
|
"main_changeset": true,
|
|
23
23
|
"main": "./Index.svelte",
|
|
@@ -14,12 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
16
|
import { type I18nFormatter } from "@gradio/utils";
|
|
17
|
-
import {
|
|
18
|
-
prepare_files,
|
|
19
|
-
upload,
|
|
20
|
-
normalise_file,
|
|
21
|
-
type FileData
|
|
22
|
-
} from "@gradio/client";
|
|
17
|
+
import { prepare_files, upload, type FileData } from "@gradio/client";
|
|
23
18
|
|
|
24
19
|
import ImageEditor from "./ImageEditor.svelte";
|
|
25
20
|
import Layers from "./layers/Layers.svelte";
|
|
@@ -36,7 +31,6 @@
|
|
|
36
31
|
export let crop_size: [number, number] | `${string}:${string}` | null = null;
|
|
37
32
|
export let i18n: I18nFormatter;
|
|
38
33
|
export let root: string;
|
|
39
|
-
export let proxy_url: string;
|
|
40
34
|
export let label: string | undefined = undefined;
|
|
41
35
|
export let show_label: boolean;
|
|
42
36
|
export let changeable = false;
|
|
@@ -136,11 +130,7 @@
|
|
|
136
130
|
{root}
|
|
137
131
|
{sources}
|
|
138
132
|
bind:bg
|
|
139
|
-
background_file={
|
|
140
|
-
value?.background || null,
|
|
141
|
-
root,
|
|
142
|
-
proxy_url
|
|
143
|
-
)}
|
|
133
|
+
background_file={value?.background || null}
|
|
144
134
|
></Sources>
|
|
145
135
|
{/if}
|
|
146
136
|
{#if transforms.includes("crop")}
|
|
@@ -161,9 +151,7 @@
|
|
|
161
151
|
{/if}
|
|
162
152
|
</Tools>
|
|
163
153
|
|
|
164
|
-
<Layers
|
|
165
|
-
layer_files={normalise_file(value?.layers || null, root, proxy_url)}
|
|
166
|
-
/>
|
|
154
|
+
<Layers layer_files={value?.layers || null} />
|
|
167
155
|
|
|
168
156
|
{#if !bg && !history}
|
|
169
157
|
<div class="empty wrap">
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { type I18nFormatter } from "@gradio/utils";
|
|
13
13
|
|
|
14
14
|
import { add_bg_color, add_bg_image } from "./sources";
|
|
15
|
-
import type { FileData
|
|
15
|
+
import type { FileData } from "@gradio/client";
|
|
16
16
|
|
|
17
17
|
export let background_file: FileData | null;
|
|
18
18
|
export let root: string;
|