@wordpress/upload-media
Version:
Core media upload logic.
35 lines • 1.24 kB
TypeScript
/**
* Image dimensions and encoding details parsed from a file header.
*/
export interface ImageDimensions {
/**
* Image width in pixels.
*/
width: number;
/**
* Image height in pixels.
*/
height: number;
/**
* Whether the image is interlaced (progressive JPEG or Adam7 PNG).
*
* Interlaced images cannot be decoded with shrink-on-load, so the full
* image must be buffered in memory at once. This matters for deciding
* whether an image is safe to process client-side within the wasm-vips
* memory cap.
*/
interlaced: boolean;
}
/**
* Reads an image's dimensions and interlacing from its header bytes.
*
* Only the leading bytes of the file are read, so this is cheap even for very
* large images and never fully decodes the pixel data. Currently supports JPEG
* and PNG, the formats most commonly affected by client-side memory limits;
* other formats return null (treated as unknown).
*
* @param file The image file to inspect.
* @return The parsed dimensions, or null if they could not be determined.
*/
export declare function getImageDimensions(file: File): Promise<ImageDimensions | null>;
//# sourceMappingURL=get-image-dimensions.d.ts.map