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-image-process

v0.2.4

Published

a image process component for react

Downloads

64

Readme

react-image-process

npm npm version jest

:art: A image process component for react, like compressed image,clip image, add watermarking of image

normal version

Installation

using yarn :

yarn add react-image-process

using npm :

npm install react-image-process --save

Screenshots

lightTheme

Example

online example : https://lijinke666.github.io/react-image-process/

Source Code

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import ReactImageProcess from 'react-image-process';

const onComplete = data => {
  console.log('data:', data);
};

ReactDOM.render(
  <ReactImageProcess mode="base64" onComplete={onComplete}>
    <img src="YOUR_IMG_URL" />
  </ReactImageProcess>,
  document.getElementById('root')
);

Support multiple Images

<ReactImageProcess mode="compress" quality={0.2} onComplete={onComplete}>
  <img src="YOUR_IMG_URL" />
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>

rotate

<ReactImageProcess mode="rotate" rotate={30}>
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>

get primary color

<ReactImageProcess mode="primaryColor" onComplete={color => console.log(color)}>
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>

waterMark

<ReactImageProcess
  mode="waterMark"
  waterMarkType="image"
  waterMark={YOUR_WATER_URL}
  width={60}
  height={60}
  opacity={0.7}
  coordinate={[430, 200]}
>
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>
<ReactImageProcess
  mode="waterMark"
  waterMarkType="text"
  waterMark={'WATER'}
  fontBold={false}
  fontSize={20}
  fontColor="#396"
  coordinate={[10, 20]}
>
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>

imageFilter

<ReactImageProcess mode="filter" filterType="vintage">
  <img src="YOUR_IMG_URL" />
</ReactImageProcess>

API

| Property | Description | Type | Default | | ------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ---------------------- | | mode | can be set to base64 clip compress rotate waterMark filter primaryColor | string | base64 | | onComplete | The callback after trans complete conversion | function(base64Data){} | - | | outputType | image data output type of blob | dataUrl | string | dataUrl | | scale | When the mode is equal to 'clip', the zoom scale of the image. | number | 1.0 | | coordinate | When the mode is equal to 'clip', coordinate of the image. like [[x1,y1],[x2,y2]], if mode equal to waterMark like [x1,y1] | number[] | - | | quality | When the mode is equal to 'compress', quality of the image. | number | 0.92 | | rotate | When the mode is equal to 'rotate', rotate deg of the image. | number | - | | waterMark | When the mode is equal to 'waterMark', can be set to image or text | string|ReactNode | - | | waterMarkType | When the mode is equal to 'waterMark', can be set to image or text | string | text | | fontBold | When the mode is equal to 'waterMark' and waterMark equal to text ,the font is bold. | boolean | false | | fontSize | When the mode is equal to 'waterMark' and waterMark equal to text ,the font size | number | 20 | | fontColor | When the mode is equal to 'waterMark' and waterMark equal to text ,the font color | string | rgba(255,255,255,.5) | | width | When the mode is equal to 'waterMark' and waterMark equal to image ,the water width | number | 50 | | height | When the mode is equal to 'waterMark' and waterMark equal to image ,the water height | number | 50 | | opacity | When the mode is equal to 'waterMark' and waterMark equal to image ,the water opacity range [0-1] | number | 0.5 | | filterType | When the mode is equal to 'filter', can be set to vintage blackWhite relief blur | string | vintage |

Development

git clone https://github.com/lijinke666/react-image-process.git
npm install
npm start

Properties

export type ReactImageProcessMode =
  | 'base64'
  | 'clip'
  | 'compress'
  | 'rotate'
  | 'waterMark'
  | 'filter'
  | 'primaryColor';

export type ReactImageProcessWaterMarkType = 'image' | 'text';
export type ReactImageProcessFilterType =
  | 'vintage'
  | 'blackWhite'
  | 'relief'
  | 'blur';
export type ReactImageProcessOutputType = 'blob' | 'dataUrl';

export interface ReactImageProcessProps {
  mode: ReactImageProcessMode;
  waterMarkType: ReactImageProcessWaterMarkType;
  filterType: ReactImageProcessFilterType;
  outputType: ReactImageProcessOutputType;
  waterMark: string;
  rotate: number;
  quality: number;
  coordinate: number[];
  width: number;
  height: number;
  opacity: number;
  fontColor: number;
  fontSize: number;
  fontBold: number;
  onComplete: (data: Blob | string) => void;
}

License

MIT