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)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more