taglib-wasm
Version:
TagLib-Wasm is the universal tagging library for TypeScript/JavaScript platforms: Browsers, Node.js, Deno, Bun, Cloudflare Workers, and Electron apps
70 lines • 2.49 kB
TypeScript
import type { Picture, PictureType } from "../types.js";
/**
* Set cover art from an HTML canvas element
*
* @param file - File path, Uint8Array buffer, ArrayBuffer, or File object
* @param canvas - HTMLCanvasElement containing the image
* @param options - Options for image format and quality
* @returns Modified file buffer with cover art from canvas
*
* @example
* ```typescript
* const canvas = document.getElementById('albumArt') as HTMLCanvasElement;
* const modifiedBuffer = await setCoverArtFromCanvas("song.mp3", canvas, {
* format: 'image/jpeg',
* quality: 0.9
* });
* ```
*/
export declare function setCoverArtFromCanvas(file: string | Uint8Array | ArrayBuffer | File, canvas: HTMLCanvasElement, options?: {
format?: "image/jpeg" | "image/png" | "image/webp";
quality?: number;
type?: PictureType;
description?: string;
}): Promise<Uint8Array>;
/**
* Convert canvas to Picture object using blob for better performance
*
* This is more efficient than toDataURL for large images as it avoids
* the base64 encoding/decoding step.
*
* @param canvas - HTMLCanvasElement containing the image
* @param options - Options for image format and quality
* @returns Promise resolving to Picture object
*
* @example
* ```typescript
* const canvas = document.getElementById('albumArt') as HTMLCanvasElement;
* const picture = await canvasToPicture(canvas, {
* format: 'image/png',
* type: PictureType.BackCover
* });
* ```
*/
export declare function canvasToPicture(canvas: HTMLCanvasElement, options?: {
format?: "image/jpeg" | "image/png" | "image/webp";
quality?: number;
type?: PictureType;
description?: string;
}): Promise<Picture>;
/**
* Load an image file into a Picture object
*
* @param file - File object from <input type="file"> or drag-and-drop
* @param type - Picture type (defaults to FrontCover)
* @param description - Optional description
* @returns Promise resolving to Picture object
*
* @example
* ```typescript
* // From file input
* const input = document.getElementById('fileInput') as HTMLInputElement;
* input.addEventListener('change', async (e) => {
* const file = e.target.files[0];
* const picture = await imageFileToPicture(file);
* const modifiedBuffer = await applyPictures("song.mp3", [picture]);
* });
* ```
*/
export declare function imageFileToPicture(file: File, type?: PictureType, description?: string): Promise<Picture>;
//# sourceMappingURL=canvas.d.ts.map