Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created Nov 24, 2022
Embed
What would you like to do?
const agregarGloboDeTextoYDevolverBuffer = async (nombreEntrada, porcentaje) => {
const entrada = sharp(nombreEntrada);
const informacionEntrada = await entrada.metadata();
const ALTURA_GLOBO = parseInt((porcentaje * informacionEntrada.height) / 100);
const globo = sharp(NOMBRE_IMAGEN_GLOBO)
.resize({ width: informacionEntrada.width, height: ALTURA_GLOBO, fit: "fill" })
return entrada
.extend({ top: ALTURA_GLOBO, background: { r: 255, g: 255, b: 255, } })
.composite([{ input: await globo.toBuffer(), left: 0, top: 0 }])
.toBuffer();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment