npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mosaic-node-generator

v1.1.5

Published

A Node module to generate mosaic images.

Downloads

14

Readme

Build Status npm version

mosaic-node-generator

A Node module to generate mosaic images.

Installation

You must have Node.js installed in your system.

Using npm:

npm install mosaic-node-generator --save

Example

Example: mosaic-node-generator-example

Code usage

Javascript

Easy example. Create a mosaic image from picture picture.jpg using the tiles from the folder pictures_folder.

var mosaic = require('mosaic-node-generator');
mosaic.mosaic( 
  'picture.jpg', 
  'pictures_folder' 
);
/**
 * Generates a mosaic image
 * @param inputImagePath The path of the input image that will be used to generate the mosaic
 * @param tilesDirectory The tiles directory we will use to read the images we will use in the mosaic generation
 * @param cellWidth The width (in pixels) of each cell in the mosaic
 * @param cellHeight The height (in pixels) of each cell in the mosaic
 * @param columns The number of columns (of tiles) of the mosaic
 * @param rows The number of rows (of tiles) of the mosaic
 * @param thumbsDirectoryFromRead We will use this folder in order to read the already generated thumbs from it
 * @param thumbsDirectoryToWrite We will use this folder in order to write the generated thumbs of the tiles
 * @param enableConsoleLogging Enable console logging
 */
function mosaic( 
  inputImagePath: string, 
  tilesDirectory?: string, 
  cellWidth?: number, 
  cellHeight?: number, 
  columns?: number, 
  rows?: number, 
  thumbsDirectoryFromRead?: string, thumbsDirectoryToWrite?: string, 
  enableConsoleLogging?: boolean
): void;

TypeScript

TODO

CLI usage

Install

Install npm package as global:

npm install mosaic-node-generator -g

Usage

mosaic-node-generator --help
Options:

-V, --version                                output the version number
    -i, --input-image [input_image]              The input image path
    -d, --tiles-directory [tiles_directory]      The tiles directory path
    -R, --thumbs-read [thumbs_read_directory]    The thumbnails read directory
    -W, --thumbs-write [thumbs_write_directory]  The thumbnails write directory
    -r, --rows [rows]                            The number of rows of the output image
    -c, --columns [columns]                      The number of columns of the output image
    -w, --cell-width [width]                     The cell width of each cell of the output image
    -h, --cell-height [height]                   The cell height of each cell of the output image
    -l, --disable-log [true/false]               Disable console logging
    -h, --help                                   output usage information

Usage example

Basic example. Create mosaic from input image and pictures folder. Write the generated thumbs from the pictures so next time we can just read the thumbs and not the pictures again:

mosaic-node-generator -i photo.jpg -d pictures_folder -W thumbs

Then we generate the mosaic again but this time reading from the thumbs generated from the last execution:

mosaic-node-generator -i photo.jpg  -R thumbs

We must take into account that if we have written the thumbnails using e.g cell_width and cell_height of 50x50 and then we generate again the mosaic reading from these thumbs, we should use a cell_width and cell_height of 50x50 again.

Test

Run Typescript tests:

npm run test:ts