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

join-images-sharp

v1.0.1

Published

Join (composite) images together automatically

Downloads

4

Readme

join-images-sharp

Join (composite) images together automatically

landscape-1 + landscape-2

output

Motivation

Needed a compact, but configurable image join utility, which I decided to open source as I like the code so much

Installation

npm i join-images-sharp

or

pnpm add join-images-sharp

or

yarn add join-images-sharp

Usage

import { joinImages } from "join-images-sharp";
// or
const { joinImages } = require("join-images-sharp");

// If using Typescript
import { joinImages, JoinImageDirection, JoinImageOptions } from "join-images-sharp";
// or
const { joinImages, JoinImageDirection, JoinImageOptions } = require("join-images-sharp");
await joinImages([
    'test-images/landscape-1.png',
    'test-images/landscape-2.png',
], 'test-images-output/output.png');

Image formats can be JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF and can be mixed and matched, eg, you can input 1 image as gif, another as jpeg and output in png.

By default, the images will join along the longest edge (as determined by isVertical = maxWidth > maxHeight), where max* is from the biggest image

You can join along the shortest edge by setting options.direction to auto-reverse, or use vertical or horizontal to set the direction manually:

await joinImages([
    'test-images/landscape-1.png',
    'test-images/landscape-2.png',
], 'test-images-output/output.png', { direction: JoinImageDirection.AutoReverse }); // or 'auto-reverse'
// or JoinImageDirection.Vertical or 'vertical'
// or JoinImageDirection.Horizontal or 'horizontal'

You can set the background color to use for any blank areas. Defaults to transparent for supporting formats (png, webp, etc), or white for other formats (jpeg, etc):

await joinImages([
    'test-images/landscape-1.png',
    'test-images/landscape-2.png',
], 'test-images-output/output.png', { background: { alpha: 0, b: 255, g: 255, r: 255 } });
// or hex
], 'test-images-output/output.png', { background: '#00FF00' });

API

| Option | Type | Description | |----------------------|----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | input | string[] | Array of image paths to join | | output | string | Output path to save composited image | | options.direction | string | JoinImageDirection | Direction in which to join the images. Defaults to auto. JoinImageDirection.Auto | auto > Join along the longest edges JoinImageDirection.AutoReverse | auto-reverse > Join along the shortest edges JoinImageDirection.Vertical | vertical > Stack images vertically JoinImageDirection.Horizontal | horizontal > Stack images horizontally | | options.background | string or { alpha: number, b: number, g: number, r: number } | Background color to use for blank areas. Defaults to transparent for supporting formats (png, webp, etc), or white for other formats (jpeg, etc) Hex string or a rgba object |

Licence

ISC

Author(s)

  • David Wakelin (https://davidwakelin.co.uk)