/** * Options for {@link prepareImage}. All fields are optional; defaults are * conservative so calling `prepareImage(file)` is safe. */ interface PrepareImageOptions { /** * Maximum file size in bytes after re-encoding. If the encoded image still * exceeds this size, `prepareImage` keeps reducing the JPEG/WebP quality * (down to 0.4) before emitting a warning. Default: 2 MiB. */ maxBytes?: number; /** Maximum width in CSS pixels after downscale. Default: 2048. */ maxWidth?: number; /** Maximum height in CSS pixels after downscale. Default: 2048. */ maxHeight?: number; /** * Output format. `auto` keeps the source format when it is JPEG, PNG or WebP, * re-encodes GIF as `image/png` (animation is flattened), and falls back to * `image/jpeg` for anything else (e.g. AVIF). * * The request is not a guarantee: a platform that cannot encode the requested * format silently produces another one, and * {@link PrepareImageResult.mediaType} then reports what was actually written. */ convertTo?: 'auto' | 'webp' | 'jpeg' | 'png'; /** Initial JPEG/WebP quality. Default: 0.85. */ quality?: number; } /** Result of preparing an image for EPUB embedding. */ interface PrepareImageResult { /** Re-encoded binary payload, ready to drop into an EPUB. */ data: Uint8Array; /** * MIME type of the bytes in {@link PrepareImageResult.data}, taken from the * encoder's output rather than from the requested format. Browsers that * cannot encode the requested format fall back to another one; a warning is * added whenever that happens. */ mediaType: string; /** Decoded pixel width after any downscale step. */ width: number; /** Decoded pixel height after any downscale step. */ height: number; /** Diagnostic notices (downscaling, quality drops, format fallbacks). */ warnings: string[]; } /** * Decodes an image, downscales it if it exceeds the given pixel bounds, and * re-encodes it to fit within {@link PrepareImageOptions.maxBytes}. * * Runs only in browsers (uses `createImageBitmap`, `OffscreenCanvas`, and * `HTMLCanvasElement`). The library itself does not depend on this module — * import it from `@libraz/mejiro/image` only when needed. */ declare function prepareImage(file: Blob | File, options?: PrepareImageOptions): Promise; export { type PrepareImageOptions, type PrepareImageResult, prepareImage };