I have after creating this test for a future project come across a task that I am unable to solve and after looking across the Internet cannot seem to find an answer that:
I would like to allow us to work out the width and height (in pixels) of an uploaded image, and then show it replacing the contents of an HTML element.
My code is copied here: https://jsfiddle.net/op4sy5g8/
If you want to get the dimensions of the image you can use:
const url = URL.createObjectURL(<File>);
const img = new Image();
img.onload = () => {
// The dimensions will be img.width and img.height
URL.revokeObjectURL(url);
}
img.src = url;