Skip to content

TehZarathustra/nodejs-meme-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-meme-generator

Nodejs promise-based meme generator, it takes an image as url and top/bottom text to generate meme as Buffer

Installation

$ npm install nodejs-meme-generator

or

$ yarn add nodejs-meme-generator

Requirements

Unless previously installed you'll need Cairo and Pango

brew install pkg-config cairo pango libpng jpeg giflib

Example

const express = require('express');
const app = express();
const PORT = 3001;
const memeLib = require('nodejs-meme-generator');

const memeGenerator = new memeLib({
  canvasOptions: { // optional
    canvasWidth: 500,
    canvasHeight: 500
  },
  fontOptions: { // optional
    fontSize: 46,
    fontFamily: 'impact',
    lineHeight: 2
  }
});

app.get('/', function (req, res) {
  memeGenerator.generateMeme({
      // you can use either topText or bottomText
      // or both of them at the same time
      topText: 'Meme',
      bottomText: 'Generator',
      // for local image you can use path 'img/folder/image.jpg'
      url: 'https://i.imgur.com/7FHoSIG.png'
    })
    .then(function(data) {
      res.set('Content-Type', 'image/png');
      res.send(data);
    })
});

app.listen(PORT, () => console.log(`Listening on ${ PORT }`));

About

Nodejs promise-based meme generator, it takes an image as url and top/bottom text to generate meme as Buffer

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published