Created
August 23, 2018 01:13
-
-
Save eduardobcastro/a4825d72521bba1f652e63d2bf2ed988 to your computer and use it in GitHub Desktop.
Watermark from buffer
This file contains hidden or 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 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