1.1.11 • Published 4 years ago

react-cam v1.1.11

Weekly downloads
141
License
Apache-2.0
Repository
github
Last release
4 years ago

react-cam

npm

HTML5 Web/Mobile camera for ReactJS

Installation

NPM

npm install react-cam

Yarn

yarn add react-cam

How to use it?

props

Prop nameOptionalDefaultDescription
showFocusYesfalseshow/hide the blue focus box, basically useless...
frontYesfalsetrue: front camera, false: rear camera
captureNoNoneA function to handle base64 string image
widthNo480Camera pixel width, percentage or absolute value
heightNo320Camera pixel height, percentage or absolute value
focusWidthYes80%Camera focus box width, percentage or absolute value
focusHeightYes50%Camera focus box height, percentage or absolute value
btnColorYes'#2acef5'Set color of the capture button
onErrorNoHandles camera error, the error object will be passed as the function argument

example

import React, { Fragment, useRef } from 'react';
import ReactDOM from 'react-dom';
import { Camera } from 'react-cam';

function capture(imgSrc) {
  console.log(imgSrc);
}

const App = () => {
  const cam = useRef(null);
  return (
    <Fragment>
      <Camera
        showFocus={true}
        front={false}
        capture={capture}
        ref={cam}
        width="80%"
        height="auto"
        focusWidth="80%"
        focusHeight="60%"
        btnColor="white"
      />
      <button onClick={img => cam.current.capture(img)}>Take image</button>
    </Fragment>
  );
};
ReactDOM.render(<App />, document.getElementById('root'));
1.1.11

4 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago