GithubHelp home page GithubHelp logo

hhy5277 / react-image-process Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lijinke666/react-image-process

0.0 2.0 0.0 2.31 MB

:art: a image process component for react

Home Page: https://lijinke666.github.io/react-image-process/

License: MIT License

JavaScript 93.42% CSS 3.61% HTML 2.97%

react-image-process's Introduction

react-image-process

npm npm version jest

๐ŸŽจ 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){} -
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

  static propTypes = {
    children: PropTypes.oneOfType([PropTypes.element, PropTypes.node]),
    mode: PropTypes.oneOf(MODE),
    waterMarkType: PropTypes.oneOf(WATER_MARK_TYPE),
    filterType: PropTypes.oneOf(FILTER_TYPE),
    waterMark: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.element,
      PropTypes.node
    ]),
    scale: PropTypes.number,
    rotate: PropTypes.number,
    quality: PropTypes.number,
    width:PropTypes.number,
    height:PropTypes.number,
    fontColor:PropTypes.string,
    fontSize: PropTypes.oneOfType([
      PropTypes.string,
      PropTypes.number
    ]),
    fontBold:PropTypes.bool,
    coordinate: PropTypes.array,
    onComplete: PropTypes.func
  };

License

MIT

react-image-process's People

Contributors

lijinke666 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.