const getImageFileSize = (file) => new Promise((resolve, reject) => { const image = new Image() image.src = window.URL.createObjectURL(file) image.onerror = reject image.onload = () => { const width = image.naturalWidth const height = image.naturalHeight window.URL.revokeObjectURL(image.src) resolve({ width, height }) } })