/**
 * Image resize utilities
 *
 * Overview
 * --------
 * This module provides a small, dependency-free utility to resize images on the client
 * (in the browser) before uploading. It works by decoding an input `File` to an
 * `ImageBitmap` (or falling back to an `HTMLImageElement`), drawing it onto a
 * `Canvas`/`OffscreenCanvas` with the requested strategy (cover/contain), and
 * then exporting the result to a new `File` with your preferred MIME type and
 * quality.
 *
 * Why resize client-side?
 * - Faster perceived uploads and lower bandwidth usage
 * - Consistent avatar sizes and formats (e.g., JPEG 400x400)
 * - No server-side transformation required for common cases
 *
 * Fit strategies
 * - `cover` (default): The image is scaled to cover the target rectangle, and
 *   the excess parts are center-cropped. Good for avatars.
 * - `contain`: The image is scaled to fit entirely within the target rectangle
 *   without cropping, letterboxing if needed. Good when you must preserve the
 *   entire image.
 *
 * Decoding & EXIF orientation
 * EXIF orientation is a piece of metadata stored inside image files
 * (usually JPEGs) that tells image renderer software how the image should be displayed
 * i.e., whether it should be rotated or flipped. This meta data is normally added
 * to photos by digital cameras and phones.
 * - When available, `createImageBitmap(file, { imageOrientation: 'from-image' })`
 *   is used to automatically respect EXIF orientation.
 * - If not available or it fails (e.g., unsupported format), we fall back to
 *   decoding via an `HTMLImageElement`.
 *
 * OffscreenCanvas
 * - If the environment supports `OffscreenCanvas`, it will be used for the draw
 *   and encode operations for better performance in some cases. Otherwise, a
 *   regular `HTMLCanvasElement` is used.
 *
 * HEIC/HEIF notes
 * - All major browsers except Safari lack native HEIC/HEIF decoding.
 *   In such cases the `resizeImage` function will throw when decoding fails.
 *   The caller should catch and fall back
 *   to using the original file or handle conversion on the server.
 * - If we need guaranteed client-side HEIC->JPEG conversion, we must add a small
 *   library or WASM module; this utility intentionally avoids extra dependencies.
 *
 * Output type & quality
 * - Default output is `image/jpeg` with `quality=0.85`, which is typically
 *   appropriate for avatars. You can switch to `image/png` to preserve
 *   transparency.
 * - The output filename extension is adjusted to match the chosen MIME type by
 *   default (e.g., `.jpg` or `.png`). You can override naming via the `rename`
 *   option.
 *
 * Error handling
 * - Throws if canvas/context cannot be created or if canvas->blob conversion fails.
 * - Decoding failures (unsupported type) will throw; caller can try/catch and
 *   fall back to the original file.
 *
 * Performance tips
 * - Keep target sizes reasonable (e.g., 256–1024 px) to avoid long processing
 *   times on modest devices.
 * - JPEG with quality 0.8–0.9 often strikes a good balance between size and
 *   perceived quality for photos/avatars.
 *
 * Usage examples
 * --------------
 * Basic usage:
 * ```ts
 * import { resizeImage } from '@limetech/lime-elements/util/image-resize';
 *
 * const processed = await resizeImage(file, {
 *   width: 400,
 *   height: 400,
 *   fit: 'cover',         // default; center-crops
 *   type: 'image/jpeg',   // default
 *   quality: 0.85,        // default
 * });
 * // Upload `processed` instead of the original file
 * ```
 *
 * With custom naming:
 * ```ts
 * const processed = await resizeImage(file, {
 *   width: 800,
 *   height: 800,
 *   fit: 'contain',
 *   type: 'image/png',
 *   rename: (name) => name.replace(/\.[^.]+$/, '') + '_resized.png',
 * });
 * ```
 *
 * In a Stencil component (simplified):
 * ```tsx
 * private async handleFilesSelected(file: File) {
 *   try {
 *     const resized = await resizeImage(file, { width: 400, height: 400 });
 *     // build your FileInfo and emit
 *   } catch {
 *     // fall back to original
 *   }
 * }
 * ```
 */
/**
 * Options for client-side image resizing.
 * @beta
 */
export type ResizeOptions = {
    /** Target width in CSS pixels. */
    width: number;
    /** Target height in CSS pixels. */
    height: number;
    /** Fit strategy; defaults to 'cover'. */
    fit?: 'cover' | 'contain';
    /** Output MIME type; 'image/jpeg' by default. */
    type?: 'image/jpeg' | 'image/png';
    /** JPEG quality (0..1); used only for 'image/jpeg'. Defaults to 0.85. */
    quality?: number;
    /** Optional renaming function. Defaults to changing extension to match MIME. */
    rename?: (originalName: string) => string;
};
/**
 * Resize an image file on the client using Canvas/OffscreenCanvas.
 * Returns a new File with the requested format and dimensions.
 *
 * Contract
 * - Input: image `File`
 * - Output: resized image as a new `File` with updated `type`, name, and size
 * - Errors: may throw on decode failure or canvas export failure
 *
 * @beta
 * @param file - The image file to resize.
 * @param options - Configuration for the resize operation.
 */
export declare function resizeImage(file: File, options: ResizeOptions): Promise<File>;
//# sourceMappingURL=image-resize.d.ts.map