Working with Uploads

Get Image Dimensions

const upload = document.querySelector('#Image');
upload.addEventListener('change', _ => {
    if(upload.files.length) {
        const img = new Image();
        var blob = URL.createObjectURL(upload.files[0]);
        img.onload = () =>  {
            console.log(`width:${img.width}, height: ${img.height}`);
            URL.revokeObjectURL(blob);
        }
        img.src = blob;
    }
})
Last updated: 1/17/2024 9:38:59 AM

Latest Updates

© 0 - 2025 - Mike Brind.
All rights reserved.
Contact me at Mike dot Brind at Outlook.com