axis-snapshot

A Node.js library written in TypeScript capable of getting snapshots from Axis Communication cameras.

Usage no npm install needed!

<script type="module">
  import axisSnapshot from 'https://cdn.skypack.dev/axis-snapshot';
</script>

README

axis-snapshot

npm version SemVer compatible dependencies Status devDependencies Status

A Node.js library written in TypeScript capable of getting snapshots from Axis Communication cameras.

Table of contents


Super simple to use

import { writeFileSync } from 'fs';
import { Connection, Protocol, Snapshot } from 'axis-snapshot';

const connection = new Connection(Protocol.Http, '192.168.1.102', 80, 'root', '32naJzkJdZ!7*HK&Dz');
const snapshot = new Snapshot(connection);

snapshot.jpeg({ compression: 20, rotation: 180 })
  .then((image: Buffer) => writeFileSync('snapshot.jpeg', image));

Installation

npm install axis-snapshot
# or
yarn add axis-snapshot

API

Snapshot

The Snapshot class is the main class in the package. With it you take BMP and JPEG snapshots given that the operations are supported by the camera.

class Snapshot {
    /**
     * Takes a {link https://wikipedia.org/wiki/BMP_file_format|BMP} snapshot from the camera.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     */
    bmp(options?: SnapshotOptions): Promise<Buffer>;

    /**
     * Takes a {link https://en.wikipedia.org/wiki/JPEG|JPEG} snapshot from the camera.
     * @throws {UnauthorizedError} User is not authorized to perform operation.
     * @throws {RequestError} Request failed.
     */
    jpeg(options?: SnapshotOptions): Promise<Buffer>;
}