Skip to content

Latest commit

 

History

History
35 lines (25 loc) · 540 Bytes

README.md

File metadata and controls

35 lines (25 loc) · 540 Bytes

crop-png

一个去除 png 图片空白区域的小插件

安装

npm install --save crop-png

使用

import { crop } from "crop-png";

import src from "./cloth_7_3.png";

export default class extends React.Component {
  state = {
    url: ""
  };

  async componentDidMount() {
    // src可以是本地图片或者网络图片
    const url = await crop(src);

    this.setState({ url });
  }

  render() {
    const { url } = this.state;
    return <img src={url} alt="" style={{ width: 100 }} />;
  }
}