Manages delegating calls to a cluster of ExifTool child processes.

NOTE: Instances are expensive!

  • use either the default exported singleton instance of this class, exiftool, or your own singleton

  • make sure you await ExifTool.end when you're done with an instance to clean up subprocesses

  • review the ExifToolOptions for configuration options--the default values are conservative to avoid overwhelming your system.

Constructors

Properties

batchCluster: BatchCluster
exiftoolPath: (() => Promise<string>) = ...

Type declaration

    • (): Promise<string>
    • Returns Promise<string>

off: (<E>(eventName, listener) => BatchClusterEmitter) = ...

Unregister life cycle event listeners. Delegates to BatchProcess.

Type declaration

    • <E>(eventName, listener): BatchClusterEmitter
    • Type Parameters

      • E extends keyof BatchClusterEvents

      Parameters

      • eventName: E
      • listener: ((...args) => void)
          • (...args): void
          • Parameters

            • Rest ...args: BatchClusterEvents[E] extends T
                  ? T extends any[any]
                      ? T<T> extends ((...args) => void)
                          ? A
                          : never
                      : never
                  : never

            Returns void

      Returns BatchClusterEmitter

on: (<E>(eventName, listener) => BatchClusterEmitter) = ...

Register life cycle event listeners. Delegates to BatchProcess.

Type declaration

    • <E>(eventName, listener): BatchClusterEmitter
    • Type Parameters

      • E extends keyof BatchClusterEvents

      Parameters

      • eventName: E
      • listener: ((...args) => void)
          • (...args): void
          • Parameters

            • Rest ...args: BatchClusterEvents[E] extends T
                  ? T extends any[any]
                      ? T<T> extends ((...args) => void)
                          ? A
                          : never
                      : never
                  : never

            Returns void

      Returns BatchClusterEmitter

Accessors

  • get busyProcs(): number
  • Returns number

    the current number of child processes currently servicing tasks

  • get ended(): boolean
  • Returns boolean

    true if .end() has been invoked

  • get pendingTasks(): number
  • Returns number

    the number of pending (not currently worked on) tasks

  • get pids(): number[]
  • Returns number[]

    the currently running ExifTool processes. Note that on Windows, these are only the process IDs of the directly-spawned ExifTool wrapper, and not the actual perl vm. This should only really be relevant for integration tests that verify processes are cleaned up properly.

  • get spawnedProcs(): number
  • Returns number

    the total number of child processes created by this instance

Methods

  • Returns {
        broken: number;
        closed: number;
        ended: number;
        ending: number;
        idle: number;
        old: number;
        proc.close: number;
        proc.disconnect: number;
        proc.error: number;
        proc.exit: number;
        startError: number;
        stderr: number;
        stderr.error: number;
        stdin.error: number;
        stdout.error: number;
        timeout: number;
        tooMany: number;
        unhealthy: number;
        worn: number;
    }

    report why child processes were recycled

    • broken: number
    • closed: number
    • ended: number
    • ending: number
    • idle: number
    • old: number
    • proc.close: number
    • proc.disconnect: number
    • proc.error: number
    • proc.exit: number
    • startError: number
    • stderr: number
    • stderr.error: number
    • stdin.error: number
    • stdout.error: number
    • timeout: number
    • tooMany: number
    • unhealthy: number
    • worn: number
  • Shut down any currently-running child processes. New child processes will be started automatically to handle new tasks.

    Parameters

    • gracefully: boolean = true

    Returns Promise<void>

  • This will strip file of all metadata tags. The original file (with the name ${FILENAME}_original) will be retained. Note that some tags, like stat information and image dimensions, are intrinsic to the file and will continue to exist if you re-read the file.

    Parameters

    • file: string

      the file to strip of metadata

    • Optional opts: {
          retain?: string[];
      } & Partial<ExifToolTaskOptions>

    Returns Promise<WriteTaskResult>

  • Shut down running ExifTool child processes. No subsequent requests will be accepted.

    This may need to be called in after or finally clauses in tests or scripts for them to exit cleanly.

    Parameters

    • gracefully: boolean = true

    Returns Promise<void>

  • Most users will not need to use enqueueTask directly. This method supports submitting custom BatchCluster tasks.

    Type Parameters

    • T

    Parameters

    Returns Promise<T>

    See

    BinaryExtractionTask for an example task implementation

  • Extract a given binary value from "tagname" tag associated to path/to/image.jpg and write it to dest (which cannot exist and whose directory must already exist).

    Parameters

    Returns Promise<void>

    a Promise<void>. The promise will be rejected if the binary output not be written to dest.

  • Extract a given binary value from "tagname" tag associated to path/to/image.jpg as a Buffer. This has the advantage of not writing to a file, but if the payload associated to tagname is large, this can cause out-of-memory errors.

    Parameters

    Returns Promise<Buffer>

    a Promise<Buffer>. The promise will be rejected if the file or tag is missing.

  • Extract the "JpgFromRaw" image in path/to/image.jpg and write it to path/to/fromRaw.jpg.

    This size of these images varies widely, and is not present in all RAW images. Nikon and Panasonic use this tag.

    Parameters

    Returns Promise<void>

    a Promise<void>. The promise will be rejected if the file could not be read or the output not written.

  • Extract the "preview" image in path/to/image.jpg and write it to path/to/preview.jpg.

    The size of these images varies widely, and is present in dSLR images. Canon, Fuji, Olympus, and Sony use this tag.

    Parameters

    Returns Promise<void>

    a Promise<void>. An Error is raised if the file could not be read or the output not written.

  • Extract the low-resolution thumbnail in path/to/image.jpg and write it to path/to/thumbnail.jpg.

    Note that these images can be less than .1 megapixels in size.

    Parameters

    Returns Promise<void>

    a Promise<void>. An Error is raised if the file could not be read or the output not written.

  • Read the tags in file.

    Type Parameters

    Parameters

    • file: string

      the file to extract metadata tags from

    • Optional optionalArgs: string[] = ...

      any additional ExifTool arguments, like "-fast" or "-fast2". Most other arguments will require you to use readRaw. Note that the default is "-fast", so if you want ExifTool to read the entire file for metadata, you should pass an empty array as the second parameter. See https://exiftool.org/#performance for more information about -fast and -fast2.

    • Optional options: Partial<{
          backfillTimezones: boolean;
          defaultVideosToUTC: boolean;
          geoTz: ((lat, lon) => Maybe<string>);
          geolocation: boolean;
          ignoreMinorErrors: boolean;
          ignoreZeroZeroLatLon: boolean;
          imageHashType: false | "MD5" | "SHA256" | "SHA512";
          includeImageDataMD5: undefined | boolean;
          inferTimezoneFromDatestampTags: (keyof Tags)[];
          inferTimezoneFromDatestamps: boolean;
          numericTags: string[];
          optionalArgs: string[];
          useMWG: boolean;
      }>

    Returns Promise<T>

    A resolved Tags promise. If there are errors during reading, the .errors field will be present.

  • Read the tags from file, without any post-processing of ExifTool values.

    You probably want read, not this method. READ THE REST OF THIS COMMENT CAREFULLY.

    If you want to extract specific tag values from a file, you may want to use this, but all data validation and inference heuristics provided by read will be skipped.

    Note that performance will be very similar to read, and will actually be worse if you don't include -fast or -fast2 (as the most expensive bit is the perl interpreter and scanning the file on disk).

    Parameters

    • file: string
    • args: string[] = []

      any additional arguments other than the file path. Note that "-json", and the Windows unicode filename handler flags, "-charset filename=utf8", will be added automatically.

    Returns Promise<RawTags>

    Note that the return value will be similar to Tags, but with no date, time, or other rich type parsing that you get from .read(). The field values will be string | number | string[].

  • Attempt to fix metadata problems in JPEG images by deleting all metadata and rebuilding from scratch. After repairing an image you should be able to write to it without errors, but some metadata from the original image may be lost in the process.

    This should only be applied as a last resort to images whose metadata is not readable via ().

    Parameters

    • inputFile: string

      the path to the problematic image

    • outputFile: string

      the path to write the repaired image

    • Optional opts: {
          allowMakerNoteRepair?: boolean;
      } & ExifToolTaskOptions

    Returns Promise<void>

    resolved when outputFile has been written.

  • Returns Promise<string>

    a promise holding the version number of the vendored ExifTool