Skip to content

danikaze/mosaikr

Repository files navigation

mosaikr

Create a mosaic from a list of images.

It uses Sharp to operate on images.

Install

Install with npm

npm install mosaikr

Usage

import { mosaikr } from 'mosaikr';

// This will create a 3x2 grid where each image is 200x200px
mosaikr({
  input: ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg'],
  columns: 3,
  rows: 2,
  width: 600,
  height: 400,
  output: 'mosaic.jpg',
});
import { mosaikr } from 'mosaikr';

// This will do the same but it won't output the image.
// Instead, a Sharp object will be returned asynchronously to allow other operations
// (note that there's no output parameter here)
const img = await mosaikr({
  input: ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg'],
  columns: 3,
  rows: 2,
  width: 600,
  height: 400,
});

// Now you can do whatever you want here
// (this code will do exactly the same as above)
img.toFormat('jpeg')
   .toFile('mosaic.jpg');

About

Create a mosaic from a list of images

Resources

Stars

Watchers

Forks

Packages

No packages published