Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created April 14, 2018 10:50
Show Gist options
  • Save conanak99/0c1bb45d12ae075e75eb5e01945cbc82 to your computer and use it in GitHub Desktop.
Save conanak99/0c1bb45d12ae075e75eb5e01945cbc82 to your computer and use it in GitHub Desktop.
const Jimp = require("jimp");
async function addMustache(url, output) {
let source = await Jimp.read(url); // Đọc ảnh từ URL
const mustache = await Jimp.read('mustache.png'); // Đọc file râu
// Gắn file râu vào vị trí x=0, y=0, lưu ra output
return source.composite(mustache, 0, 0).write(output);
}
(async () => {
const imageUrl = 'https://pbs.twimg.com/media/DWr05hUXcAA9s8n.jpg';
await addMustache(imageUrl, 'jav_rau.jpg');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment