-
-
Save parzibyte/f55fc0a729b866fad8f8b541f6977953 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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