heic-to 1.2.2 → 1.3.1

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.
@@ -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>;