Function · Desktop Services
getImageDimensions
Reads pixel dimensions from a packaged asset, local file, or PNG data URI.
@sharpts/gui · SharpTS 572a2e31be0eSignature
TypeScript
getImageDimensions(source: string): Promise<ImageDimensions>Parameters
| Name | Type | Description |
|---|---|---|
source | string | Packaged asset URI, local file path, or PNG data URI to inspect. |
Returns
Promise<ImageDimensions> — The decoded image width and height in pixels.
Remarks
Image payloads are validated without retaining the decoded image. Sources are limited to 8,192 pixels per dimension and 25 MiB of encoded data.
Throws
- When the source cannot be read, is not a supported image, or exceeds the image safety limits.
Examples
TypeScript
import { getImageDimensions } from "@sharpts/gui";
const size = await getImageDimensions("assets/logo.png");
console.log(`${size.width} x ${size.height}`);Related symbols
Source
src/SharpTS.Gui.Sdk/GuiPackage/runtime.ts:1511 at SharpTS revision 572a2e31be0e2a09be0138bc44501b34d6245b51.