Files
puton-master/src/utils/index.ts
T
2025-12-25 09:56:11 +08:00

21 lines
474 B
TypeScript

export const getLocalImageSize = (file: File) =>
new Promise<{ width: number; height: number }>((resolve) => {
const reader = new FileReader()
reader.onload = function (e: any) {
const data = e.target.result
const image = new Image()
image.onload = function () {
const width = image.width
const height = image.height
resolve({ width, height })
}
image.src = data
}
reader.readAsDataURL(file)
})