DEV Community

Mahabubur Rahman
Mahabubur Rahman

Posted on

Get Original Dimension in JavaScript

const heightInput = document.querySelector('#height');
const widthInput = document.querySelector('#width');
Enter fullscreen mode Exit fullscreen mode
    const image = new Image()
    image.src = URL.createObjectURL(file)
    image.onload = function () {
        widthInput.value = this.width
        heightInput.value = this.height
    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)