UNPKG

@mescius/dsimageviewer

Version:

Document Solutions Image Viewer

43 lines (42 loc) 2.25 kB
import { ImageFormatCode } from "../Models/Types"; /** * Image mime type. **/ export declare type ImageMimeType = 'image/png' | 'image/x-png' | 'image/jpeg' | 'image/bmp' | 'image/gif' | 'image/webp' | 'image/svg+xml' | 'image/ico' | 'image/tiff'; /** * Converts a ImageFormatCode enum value to the corresponding image MIME type. * * @param {ImageFormatCode} imageFormat - The ImageFormatCode enum value representing the image format. * @returns {ImageMimeType} - The corresponding image MIME type. */ export declare function imageFormatToMimeType(imageFormat: ImageFormatCode): ImageMimeType; /** * Converts an image MIME type to the corresponding ImageFormatCode enum value. * * @param {ImageMimeType} mimeType - The MIME type of the image. * @param {defaultFormat} mimeType - Default image format if the MIME type is not recognized * @returns {ImageFormatCode} - The corresponding ImageFormatCode enum value. */ export declare function mimeTypeToImageFormat(mimeType: ImageMimeType, defaultFormat?: ImageFormatCode): ImageFormatCode; export declare function fileNameWithoutExt(filename: string, maxExtLen?: number): string; export declare function imageFormatToFileExt(imageFormat?: ImageFormatCode): string; /** * Find the image format for the file specified by the fileOrName parameter. * @param fileOrName File object or file name string * @param defaultImageFormat Optional. */ export declare function findImageFormat(fileOrName: ImageFormatCode | File | Uint8Array | string, defaultImageFormat?: ImageFormatCode): ImageFormatCode; /** * Gets an array of supported image formats using the canvas element and its toDataURL method. * * @returns {ImageMimeType[]} - An array of supported image formats. */ export declare function getSupportedImageFormats(): ImageMimeType[]; /** * Converts an image from a given URL to a specified format with the provided MIME type. * * @param {string} imageUrl - The URL of the image. * @param {string} targetMimeType - The desired MIME type for conversion. * @returns {Promise<Blob>} - A Blob object containing the converted image. */ export declare function convertImageToFormat(imageUrl: string, targetMimeType: ImageMimeType): Promise<Blob>;