Giter Club home page Giter Club logo

camera-action's Introduction

Camera-action

Camera-action is a component to ease camera (getusermedia) management.

It's cross-browser compatible:

  • Firefox
  • Google Chrome
  • Opera

Note: getUserMedia has to be enabled in Firefox by setting the media.peerconnection.enabled option to true in about:config.

Installation

$ component install pazguille/camera-action

See: https://github.com/component/component

Standalone

Also, you can use the standalone version:

<script src="../standalone/camera-action.js"></script>

How-to

First, defines the camera's container and its options (see the API):

var container = document.querySelector('#container'),
    options = {
        'width': 640,
        'height': 480
    };

Now, requires and creates a new instance of camera-action:

var Camera = require('camera-action'),
    camera = new Camera(container, options);

Then, starts to use it!:

camera.action();

Camera... Action!

API

Camera#action()

Adds the camera to its container and starts to record.

camera.action();

Camera#pause()

Pause the camera.

camera.pause();

Camera#takePhoto(options)

Takes a snapshot from the camera.

  • width: (number) [optional] The size width of the photo. The default value is camera's width.
  • height: (number) [optional] The size height of the photo. The default value is camera's height.
  • type: (string) [optional] URL containing a representation of the image in the format specified. The default value is image/png.
  • download (boolean) [optional] Force to download the image. The default value is false.
  • jpegquality: (string) [optional] The quality level of a JPEG image in the range of 0.0 to 1.0.
camera.takePhoto({
    'width': 640,
    'height': 480,
    'download': true
});

Camera#cut()

Removes the camera from its container.

camera.cut();

Options

  • width: (number) The size width of the camera. The default value is 320.
  • height: (number)The size height of the camera. The default value is 240.
  • hd: (boolean) Turn on HD to capture in 720p (works only in Chrome). The default value is false.

Recommended sizes:

  • 1280x720
  • 960x720
  • 640x360
  • 640x480
  • 320x240
  • 320x180

### Events

  • action: emitted when the camera is started.
  • pause: emitted when the camera is paused.
  • cut: emitted when the camera is removed.
  • photo: emitted when the camera take a photo. Also, receive as parameter the dataURI of the taken photo.
  • fail: emitted when the browser doesn't support the camera feature.

Contact

License

### The MIT License Copyright (c) 2012 @pazguille

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

camera-action's People

Contributors

pazguille avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cristiandouce

camera-action's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.