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

147
Visualizações
save image automatically with javascript

I have a script that crops an image from the video stream.

    let ctx = image.getContext("2d");
    ctx.drawImage(results.image, croprect.x, croprect.y, croprectwidth, croprectheight, 0, 0, 300, 200);

In HTML

      <div id="image-div">
            <canvas id="image" width="300" height="200"></canvas>                
      </div> 

Now I need to do some image processing manipulation with it. I do 'Save as' for the test but how to do it automatically?

I tried

    const canvas = document.getElementById('image');
    const dataURL = canvas.toDataURL();
    console.log(dataURL); 

In the console, it gives an URL but when I open it, it is just a blank (white) rectangle (correct size 300x200) I want to save it to my local folder and to the backend later when the second step (image processing) of the script will work.

about 4 years ago · Juan Pablo Isaza
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