Skip to main content
TypesOption types

The types you pass to Camera: its constructor options, and the options and choices of its methods. This is one of the 5 pages of the types reference, which names every type. A field ending in ? may be absent: Slate leaves out what a camera does not report, and never guesses it.

import type { CameraOptions, TakePhotoOptions } from '@darkgrade/slate'

Options

What the methods of Camera take.

FocusDirection

Which way nudgeFocus moves focus: near towards the camera, far away from it.

type FocusDirection = 'near' | 'far'

FocusStepSize

A small, medium or large manual-focus step, like the < << <<< buttons in vendor remote apps.

type FocusStepSize = 'small' | 'medium' | 'large'

PhotoDestination

Where a photo goes: the camera's card; the card and this computer (its bytes come back); or this computer only, never saved to the card (computerOnly).

type PhotoDestination = 'card' | 'computer' | 'computerOnly'

TakePhotoOptions

What takePhoto takes. Every field is optional.

interface TakePhotoOptions {
    autofocus?: boolean
    destination?: PhotoDestination
    download?: boolean
    rawCompression?: RawCompression
    includeInfo?: boolean
}
Show TakePhotoOptions fields
autofocus?booleandefault: true

Focus before the shutter. False releases without waiting for focus.

destination?PhotoDestinationdefault: 'card'

With 'computer' the photo is still saved to the card, and its bytes are returned. With 'computerOnly' the camera sends it to the computer and does not save it to the card, so it has no media id.

See PhotoDestination.

download?booleandefault: true

False keeps every byte of the photo on the camera, even the copy some cameras send the computer to name a new file (Sony); the card's own listing confirms it. Only with destination 'card'.

rawCompression?RawCompression

RAW compression for this photo only, put back afterwards, such as 'Lossless'.

See RawCompression.

includeInfo?booleandefault: false

Also return the camera's own description of the photo (its PTP ObjectInfo) as info.

LiveViewFrameOptions

What getLiveViewFrame takes.

interface LiveViewFrameOptions {
    overlay?: boolean
}
Show LiveViewFrameOptions fields
overlay?booleandefault: false

Also read the camera's on-screen info.

ZoomDirection

Which way startZoom zooms: in towards the long end of the lens, out towards the wide end.

type ZoomDirection = 'in' | 'out'

ZoomOptions

What startZoom takes.

interface ZoomOptions {
    speed: ZoomSpeed
}
Show ZoomOptions fields
speedZoomSpeed

How fast the lens zooms.

See ZoomSpeed.

ZoomSpeed

How fast startZoom moves the lens.

type ZoomSpeed = 'slow' | 'medium' | 'fast'

MediaDownloadOptions

Progress and cancel for downloadMedia.

interface MediaDownloadOptions {
    onProgress?: (
        receivedBytes: number,
        totalBytes: number,
    ) => void
    signal?: AbortSignal
}
Show MediaDownloadOptions fields
onProgress?(receivedBytes: number, totalBytes: number) => void

Called after each chunk with the bytes received so far.

signal?AbortSignal

Cancels between chunks; the download rejects with the signal's reason.

MediaPreviewSize

The sizes getMediaPreview returns: thumbnail is the small one, preview a larger one. A file's previews lists which it offers.

type MediaPreviewSize = 'thumbnail' | 'preview'

CameraEventHandler

A handler for on: called with no arguments each time the event fires.

type CameraEventHandler = () => void

CameraEventName

settingsChanged: a setting changed on the camera. mediaAdded: a new photo or clip is on the card.

type CameraEventName = 'settingsChanged' | 'mediaAdded'

CameraOptions

What new Camera() takes. Every field is optional.

interface CameraOptions {
    logger?: Partial<LoggerConfig>
    device?: DeviceDescriptor
    transport?: TransportInterface
    usb?: USB
    transactionPolicy?: Partial<TransactionPolicy>
    keepAlive?: boolean
    vendorId?: number
    firstContact?: boolean
}
Show CameraOptions fields
logger?Partial<LoggerConfig>default: off

Logging. Off unless you turn it on: nothing is drawn in the terminal and the console is left alone.

See LoggerConfig.

device?DeviceDescriptordefault: the one attached camera

Which camera to open, such as a USB filter when several are attached. Without it, Slate opens the one attached camera.

See DeviceDescriptor.

transport?TransportInterfacedefault: USB

A transport other than the built-in USB one, such as IPTransport from @darkgrade/slate/protocol for PTP/IP.

See TransportInterface.

usb?USB

A WebUSB implementation for the built-in USB transport to use under Node.

transactionPolicy?Partial<TransactionPolicy>default: DEFAULT_TRANSACTION_POLICY

Timeouts and DeviceBusy retries for every transaction. A field you leave out keeps its default.

See TransactionPolicy.

keepAlive?booleandefault: true

Send the advertised Canon session heartbeat without changing saved body settings.

vendorId?number

Which vendor's driver to use when the transport cannot tell, as over PTP/IP. On USB the attached camera's own vendor ID decides, and a different vendorId here makes connect() fail with CameraRefusedError.

firstContact?booleandefault: true

On Node, a body outside Slate's validated list gets one read-only inventory per model+firmware per installation, shared as a first-contact profile unless telemetry is off.

ConnectOptions

How Camera.connect opens the camera.

interface ConnectOptions {
    observeOnly?: boolean
    device?: DeviceDescriptor
}
Show ConnectOptions fields
observeOnly?booleandefault: false

Read without changing any setting. Slate still opens the vendor's control session (Canon's remote and event modes, Sony's authenticated remote session) because nothing can be read without it, but it writes no host preference: Sony keeps its dial priority and saved image destination.

device?DeviceDescriptor

The body to open, when it differs from the device given to the constructor.

See DeviceDescriptor.

Other types

⌘I