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

202
Vistas
Depixelize an image

I am looking for a way to depixelize an image that I pixelized with this code. I want to know if I can change the samplesize variable value with an event listener or something like that. Thanks for reading this and I hope that someone will help me !


let c = document.createElement("canvas")
let img1 = new Image()

img1.onload = function() {
    document.getElementById("img1").remove()
    w = img1.width
    h = img1.height

    c.width =  w
    c.height = h
    ctx = c.getContext("2d")
    ctx.drawImage(img1, 0, 0,)

    let pixelarr = ctx.getImageData(0,0,w,h).data
    let samplesize = 10
    
   

  
    for(let y=0;y<h;y+=samplesize)
        for(let x=0;x<w;x+=samplesize) {
            let p = (x+(y*w))*4
            ctx.fillStyle = "rgba(" + pixelarr[p] + "," + pixelarr[p+1] + "," + pixelarr[p+2] + "," + pixelarr[p+3] + ")"
            ctx.fillRect(x,y,samplesize, samplesize)
        }

    

    let img2 = new Image()
    img2.src = c.toDataURL("img/jpeg")
    img2.width = 600
    document.body.appendChild(img2)

  
    }
    

img1.src = document.getElementById("img1").src
about 4 years ago · Santiago Gelvez
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