Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save blopa/47b25dafea7cbd97c1af92667070832d to your computer and use it in GitHub Desktop.
Save blopa/47b25dafea7cbd97c1af92667070832d to your computer and use it in GitHub Desktop.
Code for post "How to automatically create thumbnails for your videos with Node.js"
const { createCanvas, loadImage } = require('canvas');
const { writeFileSync } = require('fs');
const canvas = createCanvas(200, 200);
const ctx = canvas.getContext('2d');
ctx.font = '30px Impact';
ctx.fillStyle = '#000';
ctx.fillText('Hello World!', 0, 0);
canvas.toBuffer('image/png', (err, buffer) => {
writeFileSync('./hello-world.png', buffer);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment