Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
How to fetch width and height of image javascript

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 understand due to lack of knowledge of Javascript
  • Does not seem to work with my layout of code

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/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!