Socket
Socket
Sign inDemoInstall

react-html5-camera-photo

Package Overview
Dependencies
6
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-html5-camera-photo

React.js HTML5 Camera Photo


Version published
Weekly downloads
16K
decreased by-43.9%
Maintainers
1
Install size
870 kB
Created
Weekly downloads
 

Readme

Source

react-html5-camera-photo

The first objective of this package comes from the need to get the same look and feal of a native mobile camera app but with a react component. For those who want to build with their own css and need an abstraction of getUserMedia() take a look of jslib-html5-camera-photo with react.

Requirement

React

LiveDemo

Demo of react-html5-camera-photo

Installation

npm install --save react-html5-camera-photo
yarn add react-html5-camera-photo

Both Yarn and npm download packages from the npm registry.

Getting started

parameterDescription
onTakePhoto(dataUri):Event function called when a photo is taken. the dataUri is passed as a parameter.

Minimum ES6 example

import React, { Component } from 'react';
import Camera from 'react-html5-camera-photo';
import 'react-html5-camera-photo/build/css/index.css';

class App extends Component {
  onTakePhoto (dataUri) {
    // Do stuff with the dataUri photo...
    console.log('takePhoto');
  }

  render () {
    return (
      <div className="App">
        <Camera
          onTakePhoto = { (dataUri) => { this.onTakePhoto(dataUri); } }
        />
      </div>
    );
  }
}

export default App;

API

PropTypes

PropertiesTypeDescription
onCameraError(error): (Optional)EventCallback called with the error object as parameter when error occur while opening the camera. Often the permission.
onCameraStart(): (optional)EventCallback called when the camera is started.
onTakePhoto(dataUri): (required)EventThe function called when a photo is taken. the dataUri is passed as a parameter.
idealFacingMode (Optional)StringThe ideal facing mode of the camera, environment or user, the default is the default of the browser.
idealResolution (Optional)ObjectObject of the ideal resolution of the camera, {width: Integer, height: Integer}, the default is the default of the browser.
isMaxResolution (Optional)BooleanIf is true, the camera will start with his own maximum resolution, the default is false.
sizeFactor (Optional)NumberNumber of the factor resolution. Example, a sizeFactor of 1 get the same resolution of the camera while sizeFactor of 0.5 get the half resolution of the camera. The sizeFactor can be between range of ]0, 1] and the default value is 1.

FAQ

  1. What if i want to improve the code or add functionalities?

Keywords

FAQs

Last updated on 12 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc