1.2.3 • Published 4 years ago

image_compress_crop_preview v1.2.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

image_compress_crop_preview

NPM   License   JavaScript Style Guide   npm downloads   Bundle size   GitHub stars

Another cool React Component Library

🚀 See it in Action

Demo

Image Compress Crop Preview Input Component for React using,

browser-image-compression tinycrop curtail react-progressbar react-particles-js

Install

npm install --save image_compress_crop_preview

Usage

Demo

Default Usage

import React from 'react'

import { Squared } from 'image_compress_crop_preview'
import 'image_compress_crop_preview/dist/index.css'

const App = () => {
  return <Squared />
}
export default App

Store the Result - Base64

import React, { useEffect, useState } from 'react'

import { Squared } from 'image_compress_crop_preview'
import 'image_compress_crop_preview/dist/index.css'

const App = () => {
  const [Output, setOutput] = useState()
  
  useEffect(() => {
    console.log(Output)
  }, [Output])

  return (
    <div>
      <Squared setOutput={setOutput}/>
    </div>
  )
}
export default App

Change the limit of image compression - MB

<Squared setOutput={setOutput} mb={0.1}/>   // 100 KB

Customization

<Squared 
  defaultImg="https://cactusthemes.com/blog/wp-content/uploads/2018/01/tt_avatar_small.jpg" 
  color="red" 
  size="150px" 
  setOutput={setOutput}
/>
ParameterDescriptionDefault ValueValid Values
defaultImgDefault image placeholderMeme FaceAnything that goes within <img src=" " />
colorColor of progress bar (loading)#FFCB2B #FFCB2BHEX, RGB, Valid Color Names (RED, BLUE, etc...)
sizeDefines the size of the component - Height x Width200pxpx, em, vh, cm, mm, %, etc...
setOutputOutput Base64 will be returned as a parameter to this function.any function. It can also be a console.log 😅
mbMaximum Size of image after compression1 MBMB

Support

License

This project is licensed under the MIT License - see the LICENSE file for details