Jimp

repository·main·Indexed 12 days ago

https://github.com/jimp-dev/jimp

A pure JavaScript image processing library for Node.js with zero native dependencies. Jimp uses a plugin-based architecture to provide image manipulation capabilities including resizing, cropping, rotating, and color adjustments. It supports JPEG, PNG, BMP, TIFF, and single-frame GIF formats.

Tokens
30.5K
Snippets
136
Records
175
Agent score
96%

What's inside Jimp

  1. Overview of @jimp/plugin-color utilities

    main
    The @jimp/plugin-color package (referenced as @jimp/utils in this context) provides a collection of color and image manipulation utilities for Jimp extensions. These utilities allow for common image processing tasks such as adjusting brightness, contrast, opacity, and applying color filters like sepia or inversion.
  2. Overview of Jimp

    main
    Jimp (JavaScript Image Manipulation Program) is an image processing library for Node.js written entirely in JavaScript. It is designed to have zero native dependencies, making it highly portable and easy to install in various environments.
  3. Overview of Jimp capabilities

    main

    Jimp (JavaScript Image Manipulation Program) provides the following core capabilities:

    • Supported Formats: PNG, JPEG, BMP, GIF, and TIFF.
    • Image Manipulation: Resize, crop, apply filters, and more.
    • Extensibility: A pluggable architecture that allows you to create your own plugins to add new manipulation methods or formats.
    • Environment Agnostic: Being pure JavaScript, it can be used anywhere JavaScript runs.
  4. Use @jimp/plugin-blur to blur images

    main

    The @jimp/plugin-blur plugin provides a fast blur algorithm designed to produce an effect similar to a Gaussian blur but with significantly higher performance. It adds the following methods to the Jimp instance:

    • blur(radius): Applies a fast blur effect.
    • gaussian(radius): Applies a Gaussian blur effect.
  5. Use the @jimp/plugin-displace plugin

    main
    The @jimp/plugin-displace plugin allows you to displace an image based on a provided displacement map. This effect shifts the pixels of the source image according to the values in the map, creating warping or distortion effects. The displace method is available on the Jimp instance when this plugin is loaded.
  6. Crop an image with @jimp/plugin-crop

    main

    The @jimp/plugin-crop plugin provides functionality to extract a specific rectangular area from an image. It exposes two primary methods on the Jimp instance:

    1. crop(x, y, w, h): Manually crops the image to a specified rectangle starting at coordinates (x, y) with a width of w and a height of h.
    2. autocrop(): Automatically crops the image to remove transparent or empty borders (depending on the specific implementation details of the Jimp core).
  7. Use the @jimp/plugin-cover plugin to cover an image

    main

    The @jimp/plugin-cover plugin provides the cover method, which allows you to cover a specific area of an image within a given height and width. This is typically used to resize and crop an image so that it fills the target dimensions while maintaining its aspect ratio, with the excess parts being cropped out.

    // Usage of the cover method
    await image.cover(width, height);
  8. Resize images with @jimp/plugin-resize

    main

    The @jimp/plugin-resize plugin provides methods to change the dimensions of an image using a 2-pass bilinear algorithm. It provides three primary methods for resizing:

    • resize(width, height): Resizes the image to a specific set width and height.
    • scale(scaleFactor): Scales the image by a given factor.
    • scaleToFit(width, height): Scales the image to fit within the specified dimensions while maintaining the original aspect ratio.
  9. Use the @jimp/plugin-quantize plugin to reduce image colors

    main

    The @jimp/plugin-quantize plugin provides the quantize method, which reduces the number of colors in an image. This is useful for creating posterized effects or reducing the color palette of an image.

    // The quantize method is available on the Jimp instance
    await image.quantize();
  10. Blit an image using @jimp/plugin-blit

    main

    The @jimp/plugin-blit plugin provides the blit operation, which allows you to combine multiple bitmaps into one using a boolean function. This is a common computer graphics operation used to overlay or merge images.

    For detailed API parameters and implementation details, refer to the official Jimp documentation for the blit method.

  11. Use @jimp/tiff for TIFF image processing

    main
    @jimp/tiff is the default TIFF encoder and decoder for Jimp. It allows Jimp to read and write TIFF formatted images. As part of the Jimp ecosystem, it integrates with the core Jimp API to provide seamless image manipulation for TIFF files.