@luceosports/play-rendering 2.2.1 → 2.2.2
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/package.json
CHANGED
package/src/helpers/common.ts
CHANGED
|
@@ -29,12 +29,16 @@ export function shapeModelKeyFromImport(shapeModels: typeof ShapeModels, type: S
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export async function loadImage(src: string | Buffer) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
try {
|
|
33
|
+
const img = new Image();
|
|
34
|
+
if (typeof src === 'string') {
|
|
35
|
+
img.src = src;
|
|
36
|
+
} else {
|
|
37
|
+
img.src = 'data:image/jpeg;base64,' + src.toString('base64');
|
|
38
|
+
}
|
|
39
|
+
await img.decode();
|
|
40
|
+
return img;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
return null;
|
|
37
43
|
}
|
|
38
|
-
await img.decode();
|
|
39
|
-
return img;
|
|
40
44
|
}
|