Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda