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

image-collage-maker

v1.0.3

Published

Image-collage-maker is a Node.js package that allows you to create customizable image collages from both local and online images. The package uses `sharp` for image processing and provides various customization options, such as specifying the shape of ima

Downloads

14

Readme

image-collage-maker

image-collage-maker is a Node.js package that allows you to create customizable image collages from both local and online images. The package uses sharp for image processing and provides various customization options, such as specifying the shape of images, adding padding, and randomizing positions.

Features

  • Combine multiple images into a collage
  • Support for local and online images
  • Customizable image shapes (square, circle)
  • Random shapes and positions
  • Specify output format (JPEG, PNG, WEBP)
  • Customizable collage size, image size, padding, and background color
  • Optional output path for saving the collage

Installation

You can install ImageCollageMaker via npm:

npm install image-collage-maker

Usage

Here is an example of how to use ImageCollageMaker:

Example Usage

Place the images to be resized in the images folder. Here is an example of how to use the image-collage-maker package to create a collage:

const { createCollage, getImagesFromFolder } = require("image-collage-maker");

async function main() {
  const folderPath = "./images";
  const imagePaths = await getImagesFromFolder(folderPath);
  imagePaths.push(
    "https://images.unsplash.com/photo-1593642532973-d31b6557fa68"
  );

  const options = {
    collageSize: { width: 1000, height: 1000 },
    imagesPerRow: 4,
    padding: 20,
    margin: 20,
    outputFormat: "jpeg",
    outputQuality: 80,
    shape: "circle", // Default shape if shapesArray is not provided
    shapesArray: ["circle", "triangle", "hexagon", "rectangle"], // Optional array of shapes
    userDefinedImageSize: { width: 230, height: 230 },
    minImageSize: 100,
    maxImageSize: 300,
    outputPath: "output/collage.jpg",
    backgroundColor: "#f0f0f0", // Background color in HEX format
    imageMaskColors: ["#FF0000", "#00FF00"], // Example mask colors in HEX format
    useMasks: false, // Set to true to apply masks
  };

  try {
    await createCollage(imagePaths, options);
    console.log("Enhanced collage created and saved.");
  } catch (error) {
    console.error("Error creating collage:", error);
  }
}

main();
  • collageSize: Size of the final collage (width and height).
  • imagesPerRow: Number of images per row in the collage.
  • padding: Padding between images.
  • margin: Margin around the collage.
  • outputFormat: Format of the output collage (jpeg, png, webp).
  • outputQuality: Quality of the output collage (percentage from 0 to 100).
  • shape: Shape of the images if shapesArray is not provided.
  • shapesArray: Optional array of shapes for images.
  • userDefinedImageSize: Size of the individual images.
  • minImageSize: Minimum size for the images.
  • maxImageSize: Maximum size for the images.
  • outputPath: Path to save the output collage.
  • backgroundColor: Background color of the collage.
  • imageMaskColors: Array of colors for image masks.
  • useMasks: Set to true to apply image masks.

createCollage(imagePaths: string[], options: CollageOptions): Promise<Buffer>

Creates a collage from the provided images with the specified options.

Returns

  • A Promise that resolves to a Buffer containing the image data of the collage.

Folder Structure

ImageCollageMaker/
│
├── src/
│ ├── index.ts
│ ├── utils.ts
│ ├── types.ts
│ └── collage.ts
├── dist/
│ └── index.js (generated after compilation)
├── images/ (example folder for local images)
├── .gitignore
├── LICENSE
├── README.md
├── package.json
└── tsconfig.json

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any bugs or features.

License

This project is licensed under the MIT License. See the LICENSE file for details.