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

610
Views
Convertir una imagen en datos binarios en javascript

Posibles duplicados:
¿Obtener datos de imagen en Javascript?
¿Cómo codificar datos de imagen dentro de un archivo HTML?

¿Hay alguna forma de convertir una imagen en datos binarios en javascript y viceversa?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que obtener datos de imagen en JavaScript? responde a tu pregunta:

 // Code taken from MatthewCrumley (https://stackoverflow.com/a/934925/298479) function getBase64Image(img) { // Create an empty canvas element var canvas = document.createElement("canvas"); canvas.width = img.width; canvas.height = img.height; // Copy the image contents to the canvas var ctx = canvas.getContext("2d"); ctx.drawImage(img, 0, 0); // Get the data-URL formatted image // Firefox supports PNG and JPEG. You could check img.src to guess the // original format, but be aware the using "image/jpg" will re-encode the image. var dataURL = canvas.toDataURL("image/png"); return dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); }

Pase la etiqueta img a esta función. Devolverá la imagen en codificación base64. Sin embargo, se volverá a codificar. Por lo tanto, no puede acceder a los datos de la imagen original.

over 4 years ago · Santiago Trujillo 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!