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

123
Vistas
I am adding logo to center of qrcode but I am getting bad image quality. How to improve quality?

This is my function through which I am adding logo to qr code.

const qrcode = require('qrcode');
const { createCanvas, loadImage } = require('canvas');

//Using canvas I am adding logo to center of image(center_image) and also passing width
async function create(dataForQRcode, center_image, width, cwidth) {
  const canvas = createCanvas(width, width);
  qrcode.toCanvas(canvas, dataForQRcode, {
    errorCorrectionLevel: 'H',
    version: 5,
    margin: 1,
    color: {
      dark: '#000000',
      light: '#ffffff',
    },
  });

  const ctx = canvas.getContext('2d');
  const img = await loadImage(center_image);
  const center = (width - cwidth) / 2;

  //and using drawImage I am adding logo to qr code

  ctx.drawImage(img, center, center, cwidth, cwidth);
  return canvas.toDataURL('image/jpeg', 1.0);
}

Here I am calling the function and passing the all arguments.

const QRcode = await create(
    "Hello guys",
    "https://images.pexels.com/photos/10013232/pexels-photo-10013232.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500",
    140,
    20
);

After that I am getting the qrcode with logo at the center but the quality of logo is very bad. I don't know how to improve the quality of the image.

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