Spaces:
Sleeping
Sleeping
Download src/lib/getImageDimension.ts from ChrisJohnson111/test100: direct link, hf CLI and curl.
- Browser
- Download file 348 Bytes
-
https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/getImageDimension.ts
- Command line
-
hf download hf://spaces/ChrisJohnson111/test100/src/lib/getImageDimension.ts
-
curl -L -o getImageDimension.ts https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/getImageDimension.ts
348 Bytes
| export interface ImageDimension { | |
| width: number | |
| height: number | |
| } | |
| export async function getImageDimension(src: string): Promise<ImageDimension> { | |
| if (!src) { | |
| return { width: 0, height: 0 } | |
| } | |
| const img = new Image() | |
| img.src = src | |
| await img.decode() | |
| const width = img.width | |
| const height = img.height | |
| return { width, height } | |
| } |