
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
node-raspistill
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Simple wrapper for taking photos using Raspberry Pi raspistill app.
Module is written in typescript and provides type definitions out-of-the-box.
Tested with Raspberry Pi 2 B (Raspbian OS), and Raspberry Camera Module v2.
Raspbian OS with node.js v 8+ installed, raspberry camera module connected to your pi.
npm install node-raspistill
const Raspistill = require('node-raspistill').Raspistill;
const camera = new Raspistill();
camera.takePhoto().then((photo) => {
...
});
Or (if you use imports):
import {Raspistill} from 'node-raspistill';
const camera = new Raspistill();
camera.takePhoto().then((photo) => {
...
});
You can also pass some options to constructor method:
const camera = new Raspistill({
verticalFlip: true,
width: 800,
height: 600
});
See full options list in the docs below.
You can also find some usage examples here: https://github.com/dlukanin/node-raspistill/tree/master/examples
If you have other problems with compatibility - please create issue.
fix encoding options #20 options added #21
Fixes in interface exports.
Minor deps update. Fixes for typings location in package.json
Minor deps update. Fixes for typings location in package.json
Deps update. Vulnerability fixes.
Deps update. Added new parameters for camera options (#10, #11)
Deps update. Fixes in setting camera options methods (thx for mentioning it in PR)
Some fixes in dependencies.
New options (thx for PR): time, shutterspeed, contrast, brightness, saturation, iso.
Added raspistill stop method.
Timelapse mode. Something like beta version, can be unstable in some cases. Feel free to submit issue if you think that mode doesn't work well in your project.
Added noFileSave option. If you don't want to save photos on your raspberry pi - use this option.
Some bug fixes and new examples.
Fixed some issues with width/height options. Added setDefaultOptions method. Updated some dependencies.
Added noPreview option.
Creates new Raspistill instance.
key | type | defaults | desc |
---|---|---|---|
noFileSave | boolean | false | Disables photos saving. If true - camera output will be directly sent as Buffer without saving on the drive |
verticalFlip | boolean | false | |
horizontalFlip | boolean | false | |
noPreview | boolean | true | Disables preview window on Pi while taking photo |
outputDir | string | './photos' | Output directory where photos will be stored |
fileName | string | undefined | Name for photo file. If undefined - photos file names will be calculated as new Date.now() + file encoding |
encoding | string | 'jpg' | 'jpg', 'bmp', 'gif' or 'png' |
width | number | undefined | Width of taken image in pixels. If width is not set - raspistill uses default max camera sensor resolution width |
height | number | undefined | Height of taken image in pixels. If height is not set - raspistill uses default max camera sensor resolution height |
time | number | undefined | Time before camera takes photo. If undefined raspistill util use it's own 5 sec timeout |
shutterspeed | number | undefined | Shutter speed in microseconds |
contrast | number | undefined | Contrast of the image (-100 ... 100). If undefined - raspistill util use contrast 0 value |
brightness | number | undefined | Brightness of the image. 50 is the default raspistill util value. |
saturation | number | undefined | Image saturation (-100 ... 100). Raspistill util uses 0 value if undefined |
iso | number | undefined | Capture ISO (100 ... 800) |
rotation | number | undefined | Image rotation param |
awb | string | undefined | 'off', 'auto', 'sun', 'cloud', 'shade', 'tungsten', 'fluorescent', 'incandescent', 'flash', 'horizon' |
awbg | string | undefined | Sets blue and red gains (as floating point numbers) to be applied when awb=off. e.g. '1.5,1.2' |
quality | number | undefined | JPEG quality <0 to 100> |
thumb | string | undefined | Specification of the thumbnail image inserted into the JPEG file. If not specified, defaults are a size of 64x48 at quality 35 |
const camera = new Raspistill({
verticalFlip: true,
fileName: 'foo'
});
You can find more info about raspistill util options in the official docs: https://www.raspberrypi.org/documentation/raspbian/applications/camera.md
Takes new photo. Returns Promise, resolving with Buffer object.
camera.takePhoto('testPhotoName').then((photo) => {
...
});
Runs camera in timelapse mode. Passes taken image picture as Buffer object to the callback. Raspistill options (passed into constructor or into setOptions method) are also applicable in this mode.
Remember that raspberry camera has it's own limits of taking photos speed even in timelapse mode.
Check out official raspistill docs (https://www.raspberrypi.org/documentation/raspbian/applications/camera.md) for file naming rules and interval/total exec time params usage.
camera.timelapse(500, 3000, (image) => {
// got image from camera, do something
}).then(() => {
// timelapse ended
}).catch((err) => {
// something bad happened
});
or
camera.timelapse('image%04d', 500, 3000, (image) => {
// got image from camera, do something
}).then(() => {
// timelapse ended
}).catch((err) => {
// something bad happened
});
Tries to stop current raspistill running action. Note that pending raspistill promises will be rejected with RaspistillInterruptError if stop was completed.
const RaspistillInterruptError = require('node-raspistill').RaspistillInterruptError;
raspistill.timelapse(1000, 30000, (image) => {
console.log('got photo, trying to stop raspistill');
raspistill.stop();
})
.then(() => {
console.log('timelapse ended')
})
.catch((err) => {
console.log(err instanceof RaspistillInterruptError) // true, raspistill was interrupted;
});
Sets new options for current Raspistill instance.
camera.setOptions({
horizontalFlip: true,
noPreview: false
});
Gets current raspistill options.
Gets current raspistill option by key.
Just want to say thx for all contributors. You are wonderful. :)
Hey dude! Help me out for a couple of :beers:!
FAQs
Node wrapper for taking photos using Raspberry Pi raspistill app.
The npm package node-raspistill receives a total of 91 weekly downloads. As such, node-raspistill popularity was classified as not popular.
We found that node-raspistill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.