heic-to 1.0.1 → 1.0.3
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/README.md +4 -4
- package/dist/heic-to.d.ts +33 -0
- package/dist/heic-to.js +8 -9
- package/dist/heic-to.min.js +1 -1
- package/package.json +11 -2
- package/src/index.js +10 -11
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Currently, heic-to is using [libheif 1.18.2](https://github.com/strukturag/libhe
|
|
|
11
11
|
#### Check whether the image is HEIC or not
|
|
12
12
|
|
|
13
13
|
```js
|
|
14
|
-
import { isHeic } from "
|
|
14
|
+
import { isHeic } from "heic-to"
|
|
15
15
|
|
|
16
16
|
const file = field.files[0]
|
|
17
17
|
await isHeic(file)
|
|
@@ -21,7 +21,7 @@ await isHeic(file)
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
import { heicTo } from "
|
|
24
|
+
import { heicTo } from "heic-to"
|
|
25
25
|
|
|
26
26
|
const file = field.files[0]
|
|
27
27
|
|
|
@@ -52,7 +52,7 @@ This will open `http://127.0.0.1:8080/example/` for easy testing.
|
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
brew install cmake make pkg-config x265 libde265 libjpeg libtool
|
|
55
|
-
brew
|
|
55
|
+
brew install emscripten
|
|
56
56
|
|
|
57
57
|
git clone git@github.com:strukturag/libheif.git
|
|
58
58
|
```
|
|
@@ -69,4 +69,4 @@ cd libheif
|
|
|
69
69
|
mkdir buildjs
|
|
70
70
|
cd buildjs
|
|
71
71
|
USE_WASM=0 ../build-emscripten.sh ..
|
|
72
|
-
```
|
|
72
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a file is in HEIC format.
|
|
3
|
+
* @param file - The file to check.
|
|
4
|
+
* @returns A promise that resolves to true if the file is HEIC, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isHeic(file: File): Promise<boolean>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Options for converting HEIC images.
|
|
10
|
+
*/
|
|
11
|
+
export interface HeicToOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The HEIC image blob to convert.
|
|
14
|
+
*/
|
|
15
|
+
blob: Blob;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The desired output image MIME type (e.g., 'image/jpeg', 'image/png').
|
|
19
|
+
*/
|
|
20
|
+
type: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The quality of the output image, between 0 and 1.
|
|
24
|
+
*/
|
|
25
|
+
quality?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converts a HEIC image to another format.
|
|
30
|
+
* @param options - The conversion options.
|
|
31
|
+
* @returns A promise that resolves to the converted image blob.
|
|
32
|
+
*/
|
|
33
|
+
export declare function heicTo(options: HeicToOptions): Promise<Blob>;
|
package/dist/heic-to.js
CHANGED
|
@@ -46,17 +46,16 @@ var decodeBuffer = (buffer) => __async(void 0, null, function* () {
|
|
|
46
46
|
const id = (Math.random() * (/* @__PURE__ */ new Date()).getTime()).toString();
|
|
47
47
|
const message = { id, buffer };
|
|
48
48
|
worker.postMessage(message);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
return reject(message2.data.error);
|
|
55
|
-
}
|
|
56
|
-
return resolve(message2.data.imageData);
|
|
49
|
+
const handleEvent = (event) => {
|
|
50
|
+
if (event.data.id === id) {
|
|
51
|
+
event.currentTarget.removeEventListener("message", handleEvent);
|
|
52
|
+
if (event.data.error) {
|
|
53
|
+
return reject(event.data.error);
|
|
57
54
|
}
|
|
55
|
+
return resolve(event.data.imageData);
|
|
58
56
|
}
|
|
59
|
-
|
|
57
|
+
};
|
|
58
|
+
worker.addEventListener("message", handleEvent);
|
|
60
59
|
});
|
|
61
60
|
});
|
|
62
61
|
var encodeByCanvas = (imageBuffer) => __async(void 0, null, function* () {
|