How to use the react-image-crop.getPixelCrop function in react-image-crop

To help you get started, we’ve selected a few react-image-crop examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CheesecakeLabs / react-next-boilerplate / components / molecules / image-crop / index.js View on Github external
onImageLoaded = image => {
    const { cropShape } = this.props
    let { crop } = this.props
    // when the shape is a circle the aspect should be 1
    if (cropShape === 'circle') {
      crop = { ...crop, aspect: 1 }
    }
    const cropProperties = makeAspectCrop(
      {
        ...crop,
      },
      image.width / image.height
    )

    const pixelToCrop = getPixelCrop(image, cropProperties)
    this.setState({
      crop: cropProperties,
      originalImage: image,
      pixelCrop: pixelToCrop,
    })
  }

react-image-crop

A responsive image cropping tool for React

ISC
Latest version published 2 months ago

Package Health Score

83 / 100
Full package analysis