npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@anthonylzq/node-webcam

v2.2.0

Published

Cross platform webcam capture

Downloads

8

Readme

@anthonylzq/node-webcam

Cross platform webcam usage

Install

Linux

# Linux relies on fswebcam currently
# ubuntu

sudo apt-get install fswebcam

# arch
# fswebcam requires a build from the AUR, it is not listed for installation on pacman/pamac

sudo pamac build fswebcam

Mac OSX

# Mac OSX relies on imagesnap
# Repo https://github.com/rharder/imagesnap
# Available through brew

brew install imagesnap

Windows

Standalone exe included. See src/bindings/CommandCam

Usage

API Usage

  • The simplest use case:

    import { platform } from 'os'
    import { capture } from '@anthonylzq/node-webcam'
    
    const main = async () => {
      // base64 as default
      const result = await capture({
        location: resolve(__dirname, 'picture.jpeg'),
        type: platform()
      })
    
      console.log('result', result)
    }
  • In case you want to use another file type such as jpg, png or bmp you must indicate it in the options object, otherwise you will get an error:

    import { platform } from 'os'
    import { capture } from '@anthonylzq/node-webcam'
    
    const main = async () => {
      const result = await capture({
        location: resolve(__dirname, 'picture.png'),
        type: platform(),
        returnType: 'buffer'
        options: {
          output: 'png'
        }
      })
    
      console.log('result', result)
    }

    This is because in order to build properly the base64 image both attributes must match.

  • In case you need something more advance you can use the create function that will give you a class that will handle the usage of the webcam for you.

    import { platform } from 'os'
    import { create } from '@anthonylzq/node-webcam'
    
    // The supported platforms are: linux, darwin, win32 and win64.
    // Besides you can use 'fswebcam' as second parameter instead of "platform()"
    const Webcam = create({}, platform())
  • In case you want to list the available cameras in your OS, you can use the list function:

    import { platform } from 'os'
    import { create } from '@anthonylzq/node-webcam'
    
    const cameras = create({}, platform())
  • The default configuration for all the webcams classes and methods can be found in the defaults object:

    import { defaults } from '@anthonylzq/node-webcam'
    
    console.log(defaults)
    /**
     * {
     *   width: 1280,
     *   height: 720,
     *   delay: 0,
     *   title: '',
     *   subtitle: '',
     *   timestamp: '',
     *   saveShots: true,
     *   output: 'jpeg',
     *   device: '',
     *   callbackReturn: 'location',
     *   verbose: false,
     *   frames: 1,
     *   greyScale: false,
     *   rotation: 0,
     *   bottomBanner: false,
     *   topBanner: false,
     *   skip: 0
     * }
     */

Author

  • Charlie Abeling - Initial Work - Documentation - chuckfairy.

Maintainers

  • Anthony Luzquiños - Rework - Documentation - AnthonyLzq.