a image process component for react
npm install react-image-process


> :art: A image process component for react, like compressed image,clip image, add watermarking of image
using yarn :
```
yarn add react-image-process
using npm :
``
npm install react-image-process --save
online example : https://lijinke666.github.io/react-image-process/
`jsx
import React from 'react';
import ReactDOM from 'react-dom';
import ReactImageProcess from 'react-image-process';
const onComplete = data => {
console.log('data:', data);
};
ReactDOM.render(
document.getElementById('root')
);
`
Support multiple Images
`jsx`
> rotate
`jsx`
> get primary color
`jsx`
> waterMark
`jsx`
waterMarkType="image"
waterMark={YOUR_WATER_URL}
width={60}
height={60}
opacity={0.7}
coordinate={[430, 200]}
>
`jsx`
waterMarkType="text"
waterMark={'WATER'}
fontBold={false}
fontSize={20}
fontColor="#396"
coordinate={[10, 20]}
>
> imageFilter
`jsx`
| 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){} | |blob
| outputType | image data output type of | dataUrl | string | dataUrl |number
| scale | When the mode is equal to 'clip', the zoom scale of the image. | | 1.0 |[[x1,y1],[x2,y2]]
| coordinate | When the mode is equal to 'clip', coordinate of the image. like , if mode equal to waterMark like [x1,y1] | number[] | - |number
| quality | When the mode is equal to 'compress', quality of the image. | | 0.92 |number
| rotate | When the mode is equal to 'rotate', rotate deg of the image. | | - |image
| waterMark | When the mode is equal to 'waterMark', can be set to or text | string|ReactNode | - |image
| waterMarkType | When the mode is equal to 'waterMark', can be set to or text | string | text |text
| fontBold | When the mode is equal to 'waterMark' and waterMark equal to ,the font is bold. | boolean | false |text
| fontSize | When the mode is equal to 'waterMark' and waterMark equal to ,the font size | number | 20 |text
| fontColor | When the mode is equal to 'waterMark' and waterMark equal to ,the font color | string | rgba(255,255,255,.5) |image
| width | When the mode is equal to 'waterMark' and waterMark equal to ,the water width | number | 50 |image
| height | When the mode is equal to 'waterMark' and waterMark equal to ,the water height | number | 50 |image
| opacity | When the mode is equal to 'waterMark' and waterMark equal to ,the water opacity range [0-1] | number | 0.5 |vintage
| filterType | When the mode is equal to 'filter', can be set to blackWhite relief blur | string | vintage |
``
git clone https://github.com/lijinke666/react-image-process.git
npm install
npm start
`ts
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;
}
``