Skip to content

Commit 076f249

Browse files
Allow RawImage to read from all types of supported sources.
This will be useful for the pipeline API.
1 parent 5b5e5ed commit 076f249

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/utils/image.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class RawImage {
100100

101101
/**
102102
* Helper method for reading an image from a variety of input types.
103-
* @param {RawImage|string|URL} input
103+
* @param {RawImage|string|URL|Blob|HTMLCanvasElement|OffscreenCanvas} input
104104
* @returns The image object.
105105
*
106106
* **Example:** Read image from a URL.
@@ -119,6 +119,10 @@ export class RawImage {
119119
return input;
120120
} else if (typeof input === 'string' || input instanceof URL) {
121121
return await this.fromURL(input);
122+
} else if (input instanceof Blob) {
123+
return await this.fromBlob(input);
124+
} else if (input instanceof HTMLCanvasElement || input instanceof OffscreenCanvas) {
125+
return await this.fromCanvas(input);
122126
} else {
123127
throw new Error(`Unsupported input type: ${typeof input}`);
124128
}

0 commit comments

Comments
 (0)