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

211
Views
Cambiar el tamaño de la imagen de un formulario para enviarla redimensionada al servidor

Estoy tratando de cambiar el tamaño de una imagen que el usuario ingresa como campo de entrada en un formulario.

Esta es mi función de cambio de tamaño:

 const resizeImage = async (imageFile, max_px) => { let result = null await createImageBitmap(imageFile) .then(async (img) => { //img: [ImageBitmap] can be drawn on canvas const canvas = document.createElement("canvas"); const context = canvas.getContext("2d"); const originalWidth = img.width; const originalHeight = img.height; const maxLength = Math.max([originalWidth, originalHeight]) const resizingFactor = max_px / maxLength const canvasWidth = originalWidth * resizingFactor const canvasHeight = originalHeight * resizingFactor canvas.width = canvasWidth; canvas.height = canvasHeight; debugger context.drawImage( img, 0, 0, originalWidth * resizingFactor, originalHeight * resizingFactor ) debugger canvas.toBlob((blob) => { result = blob debugger }, 'image/jpg') debugger }) return result }

Todo está bien hasta que intento convertir el lienzo en una mancha.

Nunca se llega al depurador en la función de devolución de llamada de 'toBlob'. Qué estoy haciendo mal ?

¡Gracias por tu ayuda!

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