@gradio/image 0.22.0 → 0.22.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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @gradio/image
2
2
 
3
+ ## 0.22.1
4
+
5
+ ### Fixes
6
+
7
+ - [#10979](https://github.com/gradio-app/gradio/pull/10979) [`975feee`](https://github.com/gradio-app/gradio/commit/975feee3925e5b65e52ae00da5c5066d8889ae6a) - improve webcam options for the ImageEditor. Thanks @pngwn!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/upload@0.16.1
12
+ - @gradio/atoms@0.15.1
13
+ - @gradio/statustracker@0.10.8
14
+ - @gradio/icons@0.12.0
15
+
3
16
  ## 0.22.0
4
17
 
5
18
  ### Features
@@ -41,7 +41,11 @@
41
41
  },
42
42
  show_label: true,
43
43
  placeholder: "This is a cheetah",
44
- show_download_button: true
44
+ show_download_button: true,
45
+ webcam_options: {
46
+ mirror: true,
47
+ constraints: null
48
+ }
45
49
  }}
46
50
  play={async ({ canvasElement }) => {
47
51
  const canvas = within(canvasElement);
@@ -62,7 +66,11 @@
62
66
  orig_name: "cheetah.jpg"
63
67
  },
64
68
  show_label: false,
65
- show_download_button: false
69
+ show_download_button: false,
70
+ webcam_options: {
71
+ mirror: true,
72
+ constraints: null
73
+ }
66
74
  }}
67
75
  />
68
76
 
@@ -73,6 +81,10 @@
73
81
  path: image_file_100x1000,
74
82
  url: image_file_100x1000,
75
83
  orig_name: "image.webp"
84
+ },
85
+ webcam_options: {
86
+ mirror: true,
87
+ constraints: null
76
88
  }
77
89
  }}
78
90
  />
@@ -85,7 +97,11 @@
85
97
  url: image_file_100x1000,
86
98
  orig_name: "image.webp"
87
99
  },
88
- height: "500px"
100
+ height: "500px",
101
+ webcam_options: {
102
+ mirror: true,
103
+ constraints: null
104
+ }
89
105
  }}
90
106
  />
91
107
 
@@ -97,7 +113,11 @@
97
113
  url: image_file_100x100,
98
114
  orig_name: "image.webp"
99
115
  },
100
- height: "500px"
116
+ height: "500px",
117
+ webcam_options: {
118
+ mirror: true,
119
+ constraints: null
120
+ }
101
121
  }}
102
122
  />
103
123
 
@@ -113,7 +133,11 @@
113
133
  show_label: false,
114
134
  show_download_button: false,
115
135
  interactive: true,
116
- placeholder: md
136
+ placeholder: md,
137
+ webcam_options: {
138
+ mirror: true,
139
+ constraints: null
140
+ }
117
141
  }}
118
142
  play={async ({ canvasElement }) => {
119
143
  const canvas = within(canvasElement);
@@ -132,7 +156,11 @@
132
156
  args={{
133
157
  sources: ["webcam"],
134
158
  show_download_button: true,
135
- interactive: true
159
+ interactive: true,
160
+ webcam_options: {
161
+ mirror: true,
162
+ constraints: null
163
+ }
136
164
  }}
137
165
  />
138
166
 
@@ -156,6 +184,10 @@
156
184
  url: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
157
185
  orig_name: "cheetah.jpg"
158
186
  },
159
- streaming: true
187
+ streaming: true,
188
+ webcam_options: {
189
+ mirror: true,
190
+ constraints: null
191
+ }
160
192
  }}
161
193
  />
package/Index.svelte CHANGED
@@ -13,6 +13,7 @@
13
13
  import StaticImage from "./shared/ImagePreview.svelte";
14
14
  import ImageUploader from "./shared/ImageUploader.svelte";
15
15
  import { afterUpdate } from "svelte";
16
+ import type { WebcamOptions } from "./shared/types";
16
17
 
17
18
  import { Block, Empty, UploadText } from "@gradio/atoms";
18
19
  import { Image } from "@gradio/icons";
@@ -61,11 +62,11 @@
61
62
  export let interactive: boolean;
62
63
  export let streaming: boolean;
63
64
  export let pending: boolean;
64
- export let mirror_webcam: boolean;
65
65
  export let placeholder: string | undefined = undefined;
66
66
  export let show_fullscreen_button: boolean;
67
67
  export let input_ready: boolean;
68
- export let webcam_constraints: { [key: string]: any } | undefined = undefined;
68
+ export let webcam_options: WebcamOptions;
69
+
69
70
  let uploading = false;
70
71
  $: input_ready = !uploading;
71
72
  export let gradio: Gradio<{
@@ -215,11 +216,10 @@
215
216
  {show_label}
216
217
  {pending}
217
218
  {streaming}
218
- {mirror_webcam}
219
+ {webcam_options}
219
220
  {stream_every}
220
221
  bind:modify_stream={_modify_stream}
221
222
  bind:set_time_limit
222
- {webcam_constraints}
223
223
  max_file_size={gradio.max_file_size}
224
224
  i18n={gradio.i18n}
225
225
  upload={(...args) => gradio.client.upload(...args)}
package/dist/Index.svelte CHANGED
@@ -50,11 +50,10 @@ export let sources = [
50
50
  export let interactive;
51
51
  export let streaming;
52
52
  export let pending;
53
- export let mirror_webcam;
54
53
  export let placeholder = void 0;
55
54
  export let show_fullscreen_button;
56
55
  export let input_ready;
57
- export let webcam_constraints = void 0;
56
+ export let webcam_options;
58
57
  let uploading = false;
59
58
  $:
60
59
  input_ready = !uploading;
@@ -187,11 +186,10 @@ const handle_drop = (event) => {
187
186
  {show_label}
188
187
  {pending}
189
188
  {streaming}
190
- {mirror_webcam}
189
+ {webcam_options}
191
190
  {stream_every}
192
191
  bind:modify_stream={_modify_stream}
193
192
  bind:set_time_limit
194
- {webcam_constraints}
195
193
  max_file_size={gradio.max_file_size}
196
194
  i18n={gradio.i18n}
197
195
  upload={(...args) => gradio.client.upload(...args)}
@@ -5,6 +5,7 @@ export { default as BaseStaticImage } from "./shared/ImagePreview.svelte";
5
5
  export { default as BaseExample } from "./Example.svelte";
6
6
  export { default as BaseImage } from "./shared/Image.svelte";
7
7
  import type { Gradio, SelectData, ValueData } from "@gradio/utils";
8
+ import type { WebcamOptions } from "./shared/types";
8
9
  import { type FileData } from "@gradio/client";
9
10
  import type { LoadingStatus } from "@gradio/statustracker";
10
11
  declare const __propDef: {
@@ -34,13 +35,10 @@ declare const __propDef: {
34
35
  interactive: boolean;
35
36
  streaming: boolean;
36
37
  pending: boolean;
37
- mirror_webcam: boolean;
38
38
  placeholder?: string | undefined;
39
39
  show_fullscreen_button: boolean;
40
40
  input_ready: boolean;
41
- webcam_constraints?: {
42
- [key: string]: any;
43
- } | undefined;
41
+ webcam_options: WebcamOptions;
44
42
  gradio: Gradio<{
45
43
  input: never;
46
44
  change: never;
@@ -139,9 +137,6 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
139
137
  get pending(): boolean;
140
138
  /**accessor*/
141
139
  set pending(_: boolean);
142
- get mirror_webcam(): boolean;
143
- /**accessor*/
144
- set mirror_webcam(_: boolean);
145
140
  get placeholder(): string | undefined;
146
141
  /**accessor*/
147
142
  set placeholder(_: string | undefined);
@@ -151,13 +146,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
151
146
  get input_ready(): boolean;
152
147
  /**accessor*/
153
148
  set input_ready(_: boolean);
154
- get webcam_constraints(): {
155
- [key: string]: any;
156
- } | undefined;
149
+ get webcam_options(): WebcamOptions;
157
150
  /**accessor*/
158
- set webcam_constraints(_: {
159
- [key: string]: any;
160
- } | undefined);
151
+ set webcam_options(_: WebcamOptions);
161
152
  get gradio(): Gradio<{
162
153
  input: never;
163
154
  change: never;
@@ -16,7 +16,7 @@ export let show_label;
16
16
  export let sources = ["upload", "clipboard", "webcam"];
17
17
  export let streaming = false;
18
18
  export let pending = false;
19
- export let mirror_webcam;
19
+ export let webcam_options;
20
20
  export let selectable = false;
21
21
  export let root;
22
22
  export let i18n;
@@ -30,7 +30,6 @@ export let show_fullscreen_button = true;
30
30
  let upload_input;
31
31
  export let uploading = false;
32
32
  export let active_source = null;
33
- export let webcam_constraints = void 0;
34
33
  async function handle_upload({
35
34
  detail
36
35
  }) {
@@ -156,7 +155,7 @@ let image_container;
156
155
  on:drag
157
156
  on:upload={(e) => handle_save(e.detail, "upload")}
158
157
  on:close_stream
159
- {mirror_webcam}
158
+ mirror_webcam={webcam_options.mirror}
160
159
  {stream_every}
161
160
  {streaming}
162
161
  mode="image"
@@ -165,7 +164,7 @@ let image_container;
165
164
  {upload}
166
165
  bind:modify_stream
167
166
  bind:set_time_limit
168
- {webcam_constraints}
167
+ webcam_constraints={webcam_options.constraints}
169
168
  />
170
169
  {:else if value !== null && !streaming}
171
170
  <!-- svelte-ignore a11y-click-events-have-key-events-->
@@ -1,7 +1,7 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { type SelectData, type I18nFormatter, type ValueData } from "@gradio/utils";
3
3
  import { FileData, type Client } from "@gradio/client";
4
- import type { Base64File } from "./types";
4
+ import type { Base64File, WebcamOptions } from "./types";
5
5
  declare const __propDef: {
6
6
  props: {
7
7
  value?: null | FileData | Base64File;
@@ -10,7 +10,7 @@ declare const __propDef: {
10
10
  sources?: ("clipboard" | "upload" | "microphone" | "webcam" | null)[] | undefined;
11
11
  streaming?: boolean | undefined;
12
12
  pending?: boolean | undefined;
13
- mirror_webcam: boolean;
13
+ webcam_options: WebcamOptions;
14
14
  selectable?: boolean | undefined;
15
15
  root: string;
16
16
  i18n: I18nFormatter;
@@ -23,9 +23,6 @@ declare const __propDef: {
23
23
  show_fullscreen_button?: boolean | undefined;
24
24
  uploading?: boolean | undefined;
25
25
  active_source?: ("clipboard" | "upload" | "microphone" | "webcam" | null) | undefined;
26
- webcam_constraints?: {
27
- [key: string]: any;
28
- } | undefined;
29
26
  dragging?: boolean | undefined;
30
27
  };
31
28
  events: {
@@ -2,3 +2,7 @@ export interface Base64File {
2
2
  url: string;
3
3
  alt_text: string;
4
4
  }
5
+ export interface WebcamOptions {
6
+ mirror: boolean;
7
+ constraints: MediaStreamConstraints;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/image",
3
- "version": "0.22.0",
3
+ "version": "0.22.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/icons": "^0.11.0",
14
- "@gradio/atoms": "^0.15.0",
15
- "@gradio/statustracker": "^0.10.7",
13
+ "@gradio/atoms": "^0.15.1",
16
14
  "@gradio/client": "^1.14.1",
15
+ "@gradio/upload": "^0.16.1",
16
+ "@gradio/icons": "^0.12.0",
17
17
  "@gradio/utils": "^0.10.1",
18
- "@gradio/upload": "^0.16.0",
19
- "@gradio/wasm": "^0.18.1"
18
+ "@gradio/wasm": "^0.18.1",
19
+ "@gradio/statustracker": "^0.10.8"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@gradio/preview": "^0.13.0"
@@ -15,7 +15,7 @@
15
15
  import { FileData, type Client } from "@gradio/client";
16
16
  import { SelectSource } from "@gradio/atoms";
17
17
  import Image from "./Image.svelte";
18
- import type { Base64File } from "./types";
18
+ import type { Base64File, WebcamOptions } from "./types";
19
19
 
20
20
  export let value: null | FileData | Base64File = null;
21
21
  export let label: string | undefined = undefined;
@@ -26,7 +26,7 @@
26
26
  export let sources: source_type[] = ["upload", "clipboard", "webcam"];
27
27
  export let streaming = false;
28
28
  export let pending = false;
29
- export let mirror_webcam: boolean;
29
+ export let webcam_options: WebcamOptions;
30
30
  export let selectable = false;
31
31
  export let root: string;
32
32
  export let i18n: I18nFormatter;
@@ -43,8 +43,6 @@
43
43
  export let uploading = false;
44
44
  export let active_source: source_type = null;
45
45
 
46
- export let webcam_constraints: { [key: string]: any } | undefined = undefined;
47
-
48
46
  async function handle_upload({
49
47
  detail
50
48
  }: CustomEvent<FileData>): Promise<void> {
@@ -189,7 +187,7 @@
189
187
  on:drag
190
188
  on:upload={(e) => handle_save(e.detail, "upload")}
191
189
  on:close_stream
192
- {mirror_webcam}
190
+ mirror_webcam={webcam_options.mirror}
193
191
  {stream_every}
194
192
  {streaming}
195
193
  mode="image"
@@ -198,7 +196,7 @@
198
196
  {upload}
199
197
  bind:modify_stream
200
198
  bind:set_time_limit
201
- {webcam_constraints}
199
+ webcam_constraints={webcam_options.constraints}
202
200
  />
203
201
  {:else if value !== null && !streaming}
204
202
  <!-- svelte-ignore a11y-click-events-have-key-events-->
package/shared/types.ts CHANGED
@@ -2,3 +2,8 @@ export interface Base64File {
2
2
  url: string;
3
3
  alt_text: string;
4
4
  }
5
+
6
+ export interface WebcamOptions {
7
+ mirror: boolean;
8
+ constraints: MediaStreamConstraints;
9
+ }