heic-to 1.2.2 → 1.3.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/README.md CHANGED
@@ -8,6 +8,7 @@ Currently, heic-to is using [libheif 1.20.2](https://github.com/strukturag/libhe
8
8
 
9
9
  | Release | libheif |
10
10
  | -------- | -------- |
11
+ | 1.3.0 | 1.20.2 |
11
12
  | 1.2.2 | 1.20.2 |
12
13
  | 1.2.1 | 1.20.1 |
13
14
  | 1.2.0 | 1.20.0 |
@@ -47,7 +48,7 @@ const file = field.files[0]
47
48
  await isHeic(file)
48
49
  ```
49
50
 
50
- #### Convert HEIC to JPEG/PNG
51
+ #### Convert HEIC to JPEG/PNG/Bitmap
51
52
 
52
53
 
53
54
  ```js
@@ -66,6 +67,14 @@ const png = await heicTo({
66
67
  type: "image/png",
67
68
  quality: 0.5
68
69
  })
70
+
71
+ const bitmap = await heicTo({
72
+ blob: file,
73
+ type: "bitmap",
74
+ options: {
75
+ imageOrientation: "flipY"
76
+ }
77
+ })
69
78
  ```
70
79
 
71
80
  #### Cotent Security Policy
@@ -88,7 +97,7 @@ Fix it by using `csp/heic-to`
88
97
  If you would like to access heic-to with pure JavaScript without package builder like with CDN.
89
98
 
90
99
  ```html
91
- <script src="https://cdn.jsdelivr.net/npm/heic-to@1.2.2/dist/iife/heic-to.js"></script>
100
+ <script src="https://cdn.jsdelivr.net/npm/heic-to@1.3.0/dist/iife/heic-to.js"></script>
92
101
  <script>
93
102
  /*...*/
94
103
  if (await HeicTo.isHeic(file)) {
@@ -5,29 +5,44 @@
5
5
  */
6
6
  export declare function isHeic(file: File): Promise<boolean>;
7
7
 
8
+ type ImageMime = `${"image"}/${string}`; // e.g. "image/jpeg", "image/png", "image/webp"
9
+ type HeicTarget = "bitmap" | ImageMime;
10
+
8
11
  /**
9
- * Options for converting HEIC images.
12
+ * Converts a HEIC image to another format.
13
+ * @param args - The conversion options.
14
+ * @returns A promise that resolves to the converted image bitmap.
10
15
  */
11
- export interface HeicToOptions {
16
+ export function heicTo(args: {
12
17
  /**
13
18
  * The HEIC image blob to convert.
14
19
  */
15
20
  blob: Blob;
16
-
21
+ type: "bitmap";
17
22
  /**
18
- * The desired output image MIME type (e.g., 'image/jpeg', 'image/png').
23
+ * Options for creating the ImageBitmap.
19
24
  */
20
- type: string;
21
-
22
- /**
23
- * The quality of the output image, between 0 and 1.
24
- */
25
- quality?: number;
26
- }
25
+ options?: ImageBitmapOptions;
26
+ quality?: never;
27
+ }): Promise<ImageBitmap>;
27
28
 
28
29
  /**
29
30
  * Converts a HEIC image to another format.
30
- * @param options - The conversion options.
31
+ * @param args - The conversion options.
31
32
  * @returns A promise that resolves to the converted image blob.
32
33
  */
33
- export declare function heicTo(options: HeicToOptions): Promise<Blob>;
34
+ export function heicTo<M extends Exclude<HeicTarget, "bitmap">>(args: {
35
+ /**
36
+ * The HEIC image blob to convert.
37
+ */
38
+ blob: Blob;
39
+ /**
40
+ * The desired output image MIME type (e.g., 'image/jpeg', 'image/png').
41
+ */
42
+ type: M;
43
+ /**
44
+ * The quality of the output image, between 0 and 1.
45
+ */
46
+ quality?: number; // 0..1 for JPEG/WEBP, ignored by PNG
47
+ options?: never;
48
+ }): Promise<Blob>;