ai-comic-factory / src /lib /useImageDimension.ts
jbilcke-hf's picture
jbilcke-hf HF staff
update for oauth
3b81d2d
raw
history blame
558 Bytes
import { useEffect, useState } from "react"
import { ImageDimension, getImageDimension } from "./getImageDimension"
import { ClapMediaOrientation } from "@aitube/clap"
export function useImageDimension(src: string) {
const [dimension, setDimension] = useState<ImageDimension>({
width: 0,
height: 0,
orientation: ClapMediaOrientation.SQUARE
})
useEffect(() => {
const compute = async () => {
const newDimension = await getImageDimension(src)
setDimension(newDimension)
}
compute()
}, [src])
return dimension
}