
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
node-camera
Advanced tools
This `gphoto2` wrapper for Node.js enables you to capture images, bursts, timelapses or even video.
This rather complete Node wrapper for gphoto2*(required)* enables you to list all compatible cameras and their abilities, setup camera parameters, capture images, bursts, timelapses and even video, if supported.
As this package is a mere wrapper of the gphoto2's cli, you need to install that first:
brew install gphoto2
sudo apt-get install gphoto2
Haven't tested it, so feel free to google instructions from somebody who has.
After you have the dependencies installed, it's all easy-peasy lemon-squeezy from there:
yarn add node-camera
import { Camera, Identificator } from "node-camera";
Camera.listCameras()
.then(list => {
if (list.length) {
const CanonEOS7D = new Camera(list[0]);
CanonEOS7D.identifyBy = Identificator.Model;
CanonEOS7D.captureImage({
forceOverwrite: true,
filename: "./photo.%C"
});
setTimeout(
() =>
CanonEOS7D.captureImage(
{ forceOverwrite: true, interval: 3, filename: 'photo%03n.%C' },
{
onData: data => console.log("Received some logs: ", data.toString()),
onError: error =>
console.log("This was not supposed to happen: ", error.toString()),
onClose: exitCode =>
exitCode === 0
? console.log("Do something now with the photos")
: console.log("This without an error usually means" +
" cancellation.")
}
),
5000
);
setTimeout(() => CanonEOS7D.stopCapture(), 15000);
}
})
.catch(e => console.log(`error: ${e}`));
Noticed the timeouts? If you try to capture another image whilst a capture process is still running, you'll get an error. To prevent this, you either have to wait or kill the process by calling <CameraInstance>.stopCapture().
At line
CanonEOS7D.identifyBy = Identificator.Model;
we specify that node-camera should search for camera with name Canon EOS 7D, whereas if we write
CanonEOS7D.identifyBy = Identificator.Port;
the program will try to connect camera with the specified port. Identification by model is enabled as default, so if you have one camera only, you don't have to do anything.
However, should you have two or more cameras of the same make and model, identification by port comes in handy as it enables you to distinguish between the cameras.
The filename option accepts %a, %A, %b, %B, %d, %H, %k, %I, %l, %j, %m, %M, %S, %y, %%, (see date(1)) and, in addition, %n for the number, %C for the filename suffix, %f for the filename without suffix, %F for the foldername, %: for the complete filename in lowercase.
Note that %: is still in alpha stage, and the actual character or syntax may still be changed. E.g. it might be possible to use %#f and %#C for lower case versions, and %^f and %^C for upper case versions.
%n is the only conversion specifier to accept a padding character and width: %03n will pad with zeros to width 3 (e.g. print the number 7 as “007”). Leaving out the padding character (e.g. %3n) will use an implementation specific default padding character which may or may not be suitable for use in file names.
Camera.listCameras(): Promise<ConnectionParams>getConfigurationTree(port: string): Promise<CommandResult>Gets the whole configuration tree for the camera including current values and values that are possible to be set. This is useful e.g. for making a form to set up the camera.
Camera(cameraParams: ConnectionParams): Camera####burst({length: number, filename?: string}, callbacks?: Callbacks): void
Captures multiple images for a specified time as quickly as possible.
captureImage(options: CaptureOptions, callbacks?: Callbacks): voidCaptures image or images using provided options.
getConfig(propertyNames: string[]): Promise<CommandResult>Gets a configuration property/properties value from the camera.
reset(): Promise<CommandResult>Resets the camera's port.
####setConfig(properties: Record<string, any>): Promise<CommandResult>
Sets configuration values.
stopCapture(): voidKills an ongoing capture, e.g. when a timelapse length was set to undefined.
timelapse(options: Pick<CaptureOptions,'frames' | 'interval' | 'filename'>, callbacks?: Callbacks)Captures multiple images in specified intervals for a specified or unspecified time.
| Name | Type | Default | Description |
|---|---|---|---|
| keep | boolean | false | Keep images on camera after capturing |
| keepRAW | boolean | false | Keep RAW images on camera after capturing |
| noKeep | boolean | true | Remove images from camera after capturing |
| bulb | number | - | Set bulb exposure time in seconds |
| frames | number | infinite | Set number of frames to capture (for a finite number has to have interval set) |
| interval | number | 1 | Set capture interval in seconds |
| resetInterval | boolean | false | Reset capture interval on signal (default=no) |
| filename | string | capture%4n.%C | Specify a filename or filename pattern (see 2.1.3) |
| forceOverwrite | boolean | true | Overwrite files without asking |
| skipExisting | boolean | false | Skip existing files |
CommandResult {
error?: any;
data?: any;
}
| Name | Type | Default | Example value |
|---|---|---|---|
| model | string | - | Canon EOS 7D |
| port | string | - | usb:020,006 |
| configuration | object | - | try for yourself |
Callbacks {
onData?: (data: any) => void;
onError?: (error: any) => void;
onClose?: (exitCode: number) => void;
}
enum Identificator {
Port,
Model
}
FAQs
This `gphoto2` wrapper for Node.js enables you to capture images, bursts, timelapses or even video.
The npm package node-camera receives a total of 5 weekly downloads. As such, node-camera popularity was classified as not popular.
We found that node-camera 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.