Spaces:
Running
Running
Download src/lib/useImageDimension.ts from ChrisJohnson111/test100: direct link, hf CLI and curl.
- Browser
- Download file 461 Bytes
-
https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/useImageDimension.ts
- Command line
-
hf download hf://spaces/ChrisJohnson111/test100/src/lib/useImageDimension.ts
-
curl -L -o useImageDimension.ts https://huggingface.co/spaces/ChrisJohnson111/test100/resolve/main/src/lib/useImageDimension.ts
461 Bytes
| import { useEffect, useState } from "react" | |
| import { ImageDimension, getImageDimension } from "./getImageDimension" | |
| export function useImageDimension(src: string) { | |
| const [dimension, setDimension] = useState<ImageDimension>({ | |
| width: 0, | |
| height: 0, | |
| }) | |
| useEffect(() => { | |
| const compute = async () => { | |
| const newDimension = await getImageDimension(src) | |
| setDimension(newDimension) | |
| } | |
| compute() | |
| }, [src]) | |
| return dimension | |
| } |