image-in-browser
Version:
Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)
56 lines (55 loc) • 2.08 kB
TypeScript
/** @format */
import { MemoryImage } from '../image/image.js';
import { Decoder, DecoderDecodeOptions } from './decoder.js';
import { ImageFormat } from './image-format.js';
import { JpegInfo } from './jpeg/jpeg-info.js';
/**
* Decode a jpeg encoded image.
*/
export declare class JpegDecoder implements Decoder {
/**
* Input buffer for the JPEG data.
*/
private _input?;
/**
* Information about the JPEG image.
*/
private _info?;
/**
* Get the image format.
* @returns {ImageFormat} The format of the image, which is JPEG.
*/
get format(): ImageFormat;
/**
* Get the number of frames in the JPEG image.
* @returns {number} The number of frames.
*/
get numFrames(): number;
/**
* Is the given file a valid JPEG image?
* @param {Uint8Array} bytes - The bytes of the file to validate.
* @returns {boolean} True if the file is a valid JPEG image, false otherwise.
*/
isValidFile(bytes: Uint8Array): boolean;
/**
* Start decoding the JPEG image.
* @param {Uint8Array} bytes - The bytes of the JPEG image.
* @returns {JpegInfo | undefined} Information about the JPEG image, or undefined if decoding fails.
*/
startDecode(bytes: Uint8Array): JpegInfo | undefined;
/**
* Decode a specific frame of the JPEG image.
* @param {number} _ - The frame index (currently only single frame JPEGs are supported).
* @returns {MemoryImage | undefined} The decoded image, or undefined if decoding fails.
* @throws {LibError} If the JPEG contains more than one frame.
*/
decodeFrame(_: number): MemoryImage | undefined;
/**
* Decode the JPEG image.
* @param {DecoderDecodeOptions} opt - The options for decoding.
* @param {Uint8Array} opt.bytes - The bytes of the JPEG image.
* @returns {MemoryImage | undefined} The decoded image, or undefined if decoding fails.
* @throws {LibError} If the JPEG contains more than one frame.
*/
decode(opt: DecoderDecodeOptions): MemoryImage | undefined;
}