photo-collage
Combines several images into a photo collage.
Example
Source files
Result
Installation
npm install --save photo-collage
This library depends on node-canvas
, which may require additional setup. See their installation page for details.
Usage
The following example creates a 2x3 collage from a variety of image sources.
const createCollage = require("photo-collage");
const options = {
sources: [
imageBufferObject,
canvasObject,
"http://myurl.com/image.jpg",
"https://myurl.com/image.jpg",
"./localfile.png",
"~/photos/file.png"
],
width: 3,
height: 2,
imageWidth: 350,
imageHeight: 250,
spacing: 2,
lines: [
{font: "", color: "", text: "Sometimes we want to find out when a single one time event has"},
{font: "", color: "", text: "Sometimes we want to find out when a single one time event has"},
{font: "", color: "", text: "Sometimes we want to find out when a single one time event has"},
{font: "", color: "", text: "Sometimes we want to find out when a single one time event has"},
{font: "", color: "", text: "Sometimes we want to find out when a single one time event has"},
],
};
createCollage(options)
.then((canvas) => {
const src = canvas.jpegStream();
const dest = fs.createWriteStream("myFile");
src.pipe(dest);
});