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)
57 lines (56 loc) • 2.5 kB
TypeScript
/** @format */
import { ExifData } from '../../exif/exif-data.js';
/**
* Utility class for handling JPEG operations, including reading and writing EXIF data.
*/
export declare class JpegUtils {
/**
* EXIF signature constant.
*/
private static readonly _exifSignature;
/**
* Reads EXIF data from the given input buffer.
* @param {InputBuffer<Uint8Array> | undefined} block - The input buffer containing the EXIF data.
* @returns {ExifData | undefined} The parsed EXIF data or undefined if the data is invalid.
*/
private readExifData;
/**
* Writes the APP1 segment containing EXIF data to the output buffer.
* @param {OutputBuffer} out - The output buffer to write to.
* @param {ExifData} exif - The EXIF data to write.
*/
private writeAPP1;
/**
* Reads a block of data from the input buffer.
* @param {InputBuffer<Uint8Array>} input - The input buffer to read from.
* @returns {InputBuffer<Uint8Array> | undefined} The read block or undefined if the block length is invalid.
*/
private readBlock;
/**
* Skips a block of data in the input buffer and optionally writes it to the output buffer.
* @param {InputBuffer<Uint8Array>} input - The input buffer to read from.
* @param {OutputBuffer} [output] - The optional output buffer to write to.
* @returns {boolean} True if the block was successfully skipped, false otherwise.
*/
private skipBlock;
/**
* Reads the next marker from the input buffer and optionally writes it to the output buffer.
* @param {InputBuffer<Uint8Array>} input - The input buffer to read from.
* @param {OutputBuffer} [output] - The optional output buffer to write to.
* @returns {number} The next marker value.
*/
private nextMarker;
/**
* Decodes EXIF data from the given JPEG data.
* @param {Uint8Array} data - The JPEG data to decode.
* @returns {ExifData | undefined} The parsed EXIF data or undefined if the data is invalid.
*/
decodeExif(data: Uint8Array): ExifData | undefined;
/**
* Injects EXIF data into the given JPEG data.
* @param {ExifData} exif - The EXIF data to inject.
* @param {Uint8Array} data - The JPEG data to inject into.
* @returns {Uint8Array | undefined} The modified JPEG data with the injected EXIF data or undefined if the data is invalid.
*/
injectExif(exif: ExifData, data: Uint8Array): Uint8Array | undefined;
}