Skip to content

Instantly share code, notes, and snippets.

@eduardobcastro
Created August 23, 2018 01:13
Show Gist options
  • Save eduardobcastro/a4825d72521bba1f652e63d2bf2ed988 to your computer and use it in GitHub Desktop.
Save eduardobcastro/a4825d72521bba1f652e63d2bf2ed988 to your computer and use it in GitHub Desktop.
Watermark from buffer
const jimp = require('jimp')
const { readFile, writeFile } = require('fs')
readFile('maxresdefault.jpg', function (err, bufferImage) {
readFile('logo100.png', function (err, bufferLogo) {
jimp.read(bufferImage).then(jImage => {
jimp.read(bufferLogo).then(jLogo => {
jImage.composite(
jLogo,
jImage.getWidth() - jLogo.getWidth() - 10,
jImage.getHeight() - jLogo.getHeight() - 10,
{
mode: jimp.BLEND_SOURCE_OVER,
opacityDest: 1,
opacitySource: 0.5
})
jImage.write('output.png')
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment