@gradio/image 0.3.6 → 0.4.1
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 +60 -2
- package/Index.svelte +1 -0
- package/package.json +8 -8
- package/shared/ImagePreview.svelte +1 -0
- package/shared/Webcam.svelte +7 -10
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,68 @@
|
|
1
1
|
# @gradio/image
|
2
2
|
|
3
|
+
## 0.4.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies [[`71f1a1f99`](https://github.com/gradio-app/gradio/commit/71f1a1f9931489d465c2c1302a5c8d768a3cd23a)]:
|
8
|
+
- @gradio/client@0.8.2
|
9
|
+
- @gradio/upload@0.5.1
|
10
|
+
|
11
|
+
## 0.4.0
|
12
|
+
|
13
|
+
### Highlights
|
14
|
+
|
15
|
+
#### New `ImageEditor` component ([#6169](https://github.com/gradio-app/gradio/pull/6169) [`9caddc17b`](https://github.com/gradio-app/gradio/commit/9caddc17b1dea8da1af8ba724c6a5eab04ce0ed8))
|
16
|
+
|
17
|
+
A brand new component, completely separate from `Image` that provides simple editing capabilities.
|
18
|
+
|
19
|
+
- Set background images from file uploads, webcam, or just paste!
|
20
|
+
- Crop images with an improved cropping UI. App authors can event set specific crop size, or crop ratios (`1:1`, etc)
|
21
|
+
- Paint on top of any image (or no image) and erase any mistakes!
|
22
|
+
- The ImageEditor supports layers, confining draw and erase actions to that layer.
|
23
|
+
- More flexible access to data. The image component returns a composite image representing the final state of the canvas as well as providing the background and all layers as individual images.
|
24
|
+
- Fully customisable. All features can be enabled and disabled. Even the brush color swatches can be customised.
|
25
|
+
|
26
|
+
<video src="https://user-images.githubusercontent.com/12937446/284027169-31188926-fd16-4a1c-8718-998e7aae4695.mp4" autoplay muted></video>
|
27
|
+
|
28
|
+
```py
|
29
|
+
|
30
|
+
def fn(im):
|
31
|
+
im["composite"] # the full canvas
|
32
|
+
im["background"] # the background image
|
33
|
+
im["layers"] # a list of individual layers
|
34
|
+
|
35
|
+
|
36
|
+
im = gr.ImageEditor(
|
37
|
+
# decide which sources you'd like to accept
|
38
|
+
sources=["upload", "webcam", "clipboard"],
|
39
|
+
# set a cropsize constraint, can either be a ratio or a concrete [width, height]
|
40
|
+
crop_size="1:1",
|
41
|
+
# enable crop (or disable it)
|
42
|
+
transforms=["crop"],
|
43
|
+
# customise the brush
|
44
|
+
brush=Brush(
|
45
|
+
default_size="25", # or leave it as 'auto'
|
46
|
+
color_mode="fixed", # 'fixed' hides the user swatches and colorpicker, 'defaults' shows it
|
47
|
+
default_color="hotpink", # html names are supported
|
48
|
+
colors=[
|
49
|
+
"rgba(0, 150, 150, 1)", # rgb(a)
|
50
|
+
"#fff", # hex rgb
|
51
|
+
"hsl(360, 120, 120)" # in fact any valid colorstring
|
52
|
+
]
|
53
|
+
),
|
54
|
+
brush=Eraser(default_size="25")
|
55
|
+
)
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
Thanks [@pngwn](https://github.com/pngwn)!
|
60
|
+
|
3
61
|
## 0.3.6
|
4
62
|
|
5
63
|
### Fixes
|
6
64
|
|
7
|
-
- [#6441](https://github.com/gradio-app/gradio/pull/6441) [`2f805a7dd`](https://github.com/gradio-app/gradio/commit/2f805a7dd3d2b64b098f659dadd5d01258290521) - Small but important bugfixes for gr.Image: The upload event was not triggering at all. The paste-from-clipboard was not triggering an upload event. The clear button was not triggering a change event. The change event was triggering infinitely. Uploaded images were not preserving their original names. Uploading a new image should clear out the previous image.
|
65
|
+
- [#6441](https://github.com/gradio-app/gradio/pull/6441) [`2f805a7dd`](https://github.com/gradio-app/gradio/commit/2f805a7dd3d2b64b098f659dadd5d01258290521) - Small but important bugfixes for gr.Image: The upload event was not triggering at all. The paste-from-clipboard was not triggering an upload event. The clear button was not triggering a change event. The change event was triggering infinitely. Uploaded images were not preserving their original names. Uploading a new image should clear out the previous image. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
8
66
|
|
9
67
|
## 0.3.5
|
10
68
|
|
@@ -202,4 +260,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
|
|
202
260
|
|
203
261
|
### Features
|
204
262
|
|
205
|
-
- [#4979](https://github.com/gradio-app/gradio/pull/4979) [`44ac8ad0`](https://github.com/gradio-app/gradio/commit/44ac8ad08d82ea12c503dde5c78f999eb0452de2) - Allow setting sketch color default. Thanks [@aliabid94](https://github.com/aliabid94)!
|
263
|
+
- [#4979](https://github.com/gradio-app/gradio/pull/4979) [`44ac8ad0`](https://github.com/gradio-app/gradio/commit/44ac8ad08d82ea12c503dde5c78f999eb0452de2) - Allow setting sketch color default. Thanks [@aliabid94](https://github.com/aliabid94)!
|
package/Index.svelte
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
export { default as BaseImageUploader } from "./shared/ImageUploader.svelte";
|
6
6
|
export { default as BaseStaticImage } from "./shared/ImagePreview.svelte";
|
7
7
|
export { default as BaseExample } from "./Example.svelte";
|
8
|
+
export { default as BaseImage } from "./shared/Image.svelte";
|
8
9
|
</script>
|
9
10
|
|
10
11
|
<script lang="ts">
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gradio/image",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.1",
|
4
4
|
"description": "Gradio UI packages",
|
5
5
|
"type": "module",
|
6
6
|
"author": "",
|
@@ -10,13 +10,13 @@
|
|
10
10
|
"cropperjs": "^1.5.12",
|
11
11
|
"lazy-brush": "^1.0.1",
|
12
12
|
"resize-observer-polyfill": "^1.5.1",
|
13
|
-
"@gradio/atoms": "^0.
|
14
|
-
"@gradio/client": "^0.8.
|
15
|
-
"@gradio/
|
16
|
-
"@gradio/upload": "^0.
|
17
|
-
"@gradio/
|
18
|
-
"@gradio/
|
19
|
-
"@gradio/
|
13
|
+
"@gradio/atoms": "^0.3.0",
|
14
|
+
"@gradio/client": "^0.8.2",
|
15
|
+
"@gradio/icons": "^0.3.0",
|
16
|
+
"@gradio/upload": "^0.5.1",
|
17
|
+
"@gradio/utils": "^0.2.0",
|
18
|
+
"@gradio/statustracker": "^0.4.0",
|
19
|
+
"@gradio/wasm": "^0.3.0"
|
20
20
|
},
|
21
21
|
"main_changeset": true,
|
22
22
|
"main": "./Index.svelte",
|
package/shared/Webcam.svelte
CHANGED
@@ -15,21 +15,17 @@
|
|
15
15
|
|
16
16
|
const dispatch = createEventDispatcher<{
|
17
17
|
stream: undefined;
|
18
|
-
capture:
|
19
|
-
| {
|
20
|
-
data: FileReader["result"];
|
21
|
-
name: string;
|
22
|
-
is_example?: boolean;
|
23
|
-
is_file: boolean;
|
24
|
-
}
|
25
|
-
| Blob;
|
18
|
+
capture: Blob;
|
26
19
|
error: string;
|
27
20
|
start_recording: undefined;
|
28
21
|
stop_recording: undefined;
|
29
22
|
}>();
|
30
23
|
|
31
24
|
onMount(() => (canvas = document.createElement("canvas")));
|
32
|
-
|
25
|
+
const size = {
|
26
|
+
width: { ideal: 1920 },
|
27
|
+
height: { ideal: 1440 }
|
28
|
+
};
|
33
29
|
async function access_webcam(device_id?: string): Promise<void> {
|
34
30
|
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
35
31
|
dispatch("error", i18n("image.no_webcam_support"));
|
@@ -37,7 +33,7 @@
|
|
37
33
|
}
|
38
34
|
try {
|
39
35
|
stream = await navigator.mediaDevices.getUserMedia({
|
40
|
-
video: device_id ? { deviceId: { exact: device_id } } :
|
36
|
+
video: device_id ? { deviceId: { exact: device_id }, ...size } : size,
|
41
37
|
audio: include_audio
|
42
38
|
});
|
43
39
|
video_source.srcObject = stream;
|
@@ -95,6 +91,7 @@
|
|
95
91
|
ReaderObj.onload = function (e): void {
|
96
92
|
if (e.target) {
|
97
93
|
dispatch("capture", {
|
94
|
+
//@ts-ignore
|
98
95
|
data: e.target.result,
|
99
96
|
name: "sample." + mimeType.substring(6),
|
100
97
|
is_example: false,
|