heic-to 1.0.0

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/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ nodejs 18.14.1
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # heic-to
2
+
3
+ Convert HEIC/HEIF images to JPEG, PNG in browser using Javascript.
4
+
5
+ Inspired by [heic2any](https://github.com/alexcorvi/heic2any) and [libheif-web](https://github.com/joutvhu/libheif-web). The purpose of heic-to is to continuously follow up on releases of [libheif](https://github.com/strukturag/libheif) to be able to preview HEIC/HEIF images in browser.
6
+
7
+ Currently, heic-to is using libheif 1.18.1 under the hood.
8
+
9
+ ### Usage
10
+
11
+ #### Check whether the image is HEIC or not
12
+
13
+ ```js
14
+ import { isHeic } from "hiec-to"
15
+
16
+ const file = field.files[0]
17
+ await isHeic(file)
18
+ ```
19
+
20
+ #### Convert HEIC to JPEG/PNG
21
+
22
+
23
+ ```js
24
+ import { heicTo } from "hiec-to"
25
+
26
+ const file = field.files[0]
27
+
28
+ const jpeg = await heicTo({
29
+ blob: file,
30
+ type: "image/jpeg",
31
+ quality: 0.5
32
+ })
33
+
34
+ const png = await heicTo({
35
+ blob: file,
36
+ type: "image/png",
37
+ quality: 0.5
38
+ })
39
+ ```
40
+
41
+ ### Development guide
42
+
43
+ #### How to fast test your changes on local?
44
+
45
+ ```bash
46
+ yarn s
47
+ ```
48
+
49
+ This will open `http://127.0.0.1:8080/example/` for easy testing.
50
+
51
+ #### How to build libheif.js from [libheif](https://github.com/strukturag/libheif) on Mac
52
+
53
+ ```bash
54
+ brew install cmake make pkg-config x265 libde265 libjpeg libtool
55
+ brew instll emscripten
56
+
57
+ git clone git@github.com:strukturag/libheif.git
58
+ ```
59
+
60
+ Did below changes from `build-emscripten.sh`
61
+ ```diff
62
+ # EXPORTED_FUNCTIONS=$($EMSDK/upstream/bin/llvm-nm $LIBHEIFA --format=just-symbols | grep "^heif_\|^de265_\|^aom_" | grep "[^:]$" | sed 's/^/_/' | paste -sd "," -)
63
+ EXPORTED_FUNCTIONS=$(/opt/homebrew/opt/llvm/bin/llvm-nm $LIBHEIFA --format=just-symbols | grep "^heif_\|^de265_\|^aom_" | grep "[^:]$" | sed 's/^/_/' | paste -sd "," -)
64
+ ```
65
+
66
+ Start building
67
+ ```bash
68
+ cd libheif
69
+ mkdir buildjs
70
+ cd buildjs
71
+ USE_WASM=0 ../build-emscripten.sh ..
72
+ ```