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

react-jimp

v1.1.7

Published

JIMP library integrated to React for image manipulation

Downloads

205

Readme

React JIMP

JIMP's React implementation for image manipulation

NPM JavaScript Style Guide

Installation

npm install --save react-jimp

Example usage (width, height and alt are optional):

  • Add loadBlur to display blurred image on load
import { Jimage } from "react-jimp";
import testImage from "../assets/testimg.png";

function App() {
  return (
    <div className="App">
      // Pass the props as shown in the documentation
      <Jimage
        src={testImage}
        pixelate="5"
        mirror="true, false"
        greyscale
        color={[{ apply: "hue", params: [-90] }]}
        loadBlur
      />
    </div>
  );
}

Methods

Import the component from package

{
 /* Resize */
 contain: "w, h",  // scale the image to the given width and height, some parts of the image may be letter boxed
 cover: "w, h", // scale the image to the given width and height, some parts of the image may be clipped
 resize: "w, h", // resize the image. Jimp.AUTO can be passed as one of the values.
 scale: "f",  // scale the image by the factor f
 scaleToFit: "w, h",  // scale the image to the largest size that fits inside the given width and height
 // An optional resize mode can be passed with all resize methods.

 /* Crop */
 autocrop: "tolerance, frames", // automatically crop same-color borders from image (if any), frames must be a Boolean
 autocrop: "options",  // automatically crop same-color borders from image (if any), options may contain tolerance, cropOnlyFrames, cropSymmetric, leaveBorder
 crop: "x, y, w, h",  // crop to the given region

 /* Flip and rotate */
 flip: "horz, vert",  // flip the image horizontally or vertically
 mirror: "horz, vert",  // an alias for flip
 rotate: "deg",  // rotate the image clockwise by a number of degrees. Optionally, a resize mode can be passed. If `false` is passed as the second parameter, the image width and height will not be resized.

 /* Colour */

 brightness: "val",  // adjust the brighness by a value -1 to +1
 contrast: "val", // adjust the contrast by a value -1 to +1
 dither565: "bool" , // ordered dithering of the image and reduce color space to 16-bits (RGB565)
 greyscale: "bool",  // remove colour from the image
 invert: "bool",  // invert the image colours
 normalize: "bool",  // normalize the channels in an image

 /* Alpha channel */

 hasAlpha: "bool",  // determines if an image contains opaque pixels
 fade: "f",  // an alternative to opacity, fades the image by a factor 0 - 1. 0 will haven no effect. 1 will turn the image
 opacity: "f",  // multiply the alpha channel by each pixel by the factor f, 0 - 1
 opaque: "bool",  // set the alpha channel on every pixel to fully opaque
 background: "hex",  // set the default new pixel colour (e.g. 0xFFFFFFFF or 0x00000000) for by some operations (e.g. image.contain and

 /* Blurs */

 gaussian: "r",  // Gaussian blur the image by r pixels (VERY slow)
 blur: "r", // fast blur the image by r pixels

 /* Effects */

 posterize: "n",  // apply a posterization effect with n level
 sepia: "bool",  // apply a sepia wash to the image
 pixelate: "size"  // apply a pixelation effect to the image
}

Colour manipulation

<Jimage
 src="./img.jpg"
 color={[
  { apply: 'hue', params: [-90] },
  { apply: 'lighten', params: [50] },
  { apply: 'xor', params: ['#06D'] }
 ]}
>

The method supports the following modifiers:

| Modifier | Description | | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | lighten {amount} | Lighten the color a given amount, from 0 to 100. Providing 100 will always return white (works through TinyColor) | | brighten {amount} | Brighten the color a given amount, from 0 to 100 (works through TinyColor) | | darken {amount} | Darken the color a given amount, from 0 to 100. Providing 100 will always return black (works through TinyColor) | | desaturate {amount} | Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale (works through TinyColor) | | saturate {amount} | Saturate the color a given amount, from 0 to 100 (works through TinyColor) | | greyscale {amount} | Completely desaturates a color into greyscale (works through TinyColor) | | spin {degree} | Spin the hue a given amount, from -360 to 360. Calling with 0, 360, or -360 will do nothing - since it sets the hue back to what it was before. (works through TinyColor) | | hue {degree} | Alias for spin | | mix {color, amount} | Mixes colors by their RGB component values. Amount is opacity of overlaying color | | tint {amount} | Same as applying mix with white color | | shade {amount} | Same as applying mix with black color | | xor {color} | Treats the two colors as bitfields and applies an XOR operation to the red, green, and blue components | | red {amount} | Modify Red component by a given amount | | green {amount} | Modify Green component by a given amount | | blue {amount} | Modify Blue component by a given amount |

License

MIT © AykutSarac# React Jimp JavaScript Image Manipulation Program (JIMP) 's component based React implementation. JIMP is an image processing library for Node written entirely in JavaScript, with zero native dependencies.