nf-photo-collage
Combines several images into a photo collage.
This is slightly restructured version of original photo-collage repo. It is also using RectangleEquals fork so it is using Canvas v2.
Changes
- Removed header and support for adding text
- Add support for adding image as background
- Add typings (
index.d.ts
)
Installation
yarn add nf-photo-collage
This library depends on node-canvas
(v2), which may require additional setup. See their installation page for details.
Usage
import createCollage from "nf-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,
backgroundImage: "./localfile.png"
spacing: 2,
};
createCollage(options)
.then((canvas) => {
const src = canvas.jpegStream();
const dest = fs.createWriteStream("myFile");
src.pipe(dest);
});
Example
Source files
Result