Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda