heic-d-code 0.0.1 → 0.0.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/Heic-D-Code.d.ts +5 -5
- package/Heic-D-Code.wasm +0 -0
- package/README.md +10 -6
- package/package.json +1 -1
package/Heic-D-Code.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
|
|
2
2
|
// An ImageData-like object because ImageData isn't transferrable
|
|
3
|
-
export type DecodeOutput =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export type DecodeOutput = [
|
|
4
|
+
ImageDataArray,
|
|
5
|
+
number,
|
|
6
|
+
number,
|
|
7
|
+
];
|
|
8
8
|
|
|
9
9
|
export type Module = {
|
|
10
10
|
decode(inData: Uint8Array): DecodeOutput;
|
package/Heic-D-Code.wasm
CHANGED
|
Binary file
|
package/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# Heic-D-Code
|
|
2
|
+
|
|
2
3
|
- A wasm build of libheif whose only purpose is to decode `.heif` image or the first image of a `.heic` for use in a browser. Its size is half of other libraries like `heic2any` or `heic-to`.
|
|
3
4
|
- Used in [SnapFridge](https://github.com/msqr1/SnapFridge)
|
|
4
|
-
- Version: libde265 1.0.16, libheif 1.
|
|
5
|
+
- Version: libde265 1.0.16, libheif 1.20.1, emscripten 4.0.12
|
|
5
6
|
|
|
6
7
|
# Building instruction (from scratch)
|
|
8
|
+
|
|
9
|
+
Try to use Ninja
|
|
10
|
+
|
|
7
11
|
```bash
|
|
8
12
|
git clone --depth 1 https://github.com/msqr1/Heic-D-Code &&
|
|
9
13
|
cd Heic-D-Code &&
|
|
@@ -16,6 +20,7 @@ cmake --build . --config Release -j$(nproc)
|
|
|
16
20
|
```
|
|
17
21
|
|
|
18
22
|
# Usage
|
|
23
|
+
|
|
19
24
|
```mjs
|
|
20
25
|
import initDecoder from "./Heic-D-Code.js";
|
|
21
26
|
|
|
@@ -26,12 +31,11 @@ const context = canvas.getContext("2d");
|
|
|
26
31
|
try {
|
|
27
32
|
const heic = await fetch("example.heic");
|
|
28
33
|
const inData = await heic.bytes();
|
|
29
|
-
const
|
|
34
|
+
const decodeOutput = decoder.decode(inData);
|
|
30
35
|
canvas.width = width;
|
|
31
36
|
canvas.height = height;
|
|
32
|
-
ctx.putImageData(new ImageData(
|
|
33
|
-
}
|
|
34
|
-
catch(e) {
|
|
37
|
+
ctx.putImageData(new ImageData(...decodeOutput), 0, 0);
|
|
38
|
+
} catch (e) {
|
|
35
39
|
console.log(e);
|
|
36
40
|
}
|
|
37
|
-
```
|
|
41
|
+
```
|
package/package.json
CHANGED