Options
All
  • Public
  • Public/Protected
  • All
Menu

Manages delegating calls to a vendored running instance of ExifTool.

Instances should be shared: consider using the exported singleton instance of this class, exiftool.

Hierarchy

  • ExifTool

Index

Constructors

Properties

on: { (event: "childStart", listener: (childProcess: ChildProcess) => void): void; (event: "childExit", listener: (childProcess: ChildProcess) => void): void; (event: "startError", listener: (err: Error) => void): void; (event: "internalError", listener: (err: Error) => void): void; (event: "taskData", listener: (data: string | Buffer, task: undefined | Task<any>) => void): void; (event: "taskResolved", listener: (task: Task<any>, proc: BatchProcess) => void): void; (event: "taskError", listener: (err: Error, task: Task<any>, proc: BatchProcess) => void): void; (event: "healthCheckError", listener: (err: Error, proc: BatchProcess) => void): void; (event: "endError", listener: (err: Error) => void): void; (event: "beforeEnd", listener: () => void): void; (event: "end", listener: () => void): void } = ...

Type declaration

    • (event: "childStart", listener: (childProcess: ChildProcess) => void): void
    • (event: "childExit", listener: (childProcess: ChildProcess) => void): void
    • (event: "startError", listener: (err: Error) => void): void
    • (event: "internalError", listener: (err: Error) => void): void
    • (event: "taskData", listener: (data: string | Buffer, task: undefined | Task<any>) => void): void
    • (event: "taskResolved", listener: (task: Task<any>, proc: BatchProcess) => void): void
    • (event: "taskError", listener: (err: Error, task: Task<any>, proc: BatchProcess) => void): void
    • (event: "healthCheckError", listener: (err: Error, proc: BatchProcess) => void): void
    • (event: "endError", listener: (err: Error) => void): void
    • (event: "beforeEnd", listener: () => void): void
    • (event: "end", listener: () => void): void
    • Emitted when a child process has started

      Parameters

      • event: "childStart"
      • listener: (childProcess: ChildProcess) => void
          • (childProcess: ChildProcess): void
          • Parameters

            • childProcess: ChildProcess

            Returns void

      Returns void

    • Emitted when a child process has exitted

      Parameters

      • event: "childExit"
      • listener: (childProcess: ChildProcess) => void
          • (childProcess: ChildProcess): void
          • Parameters

            • childProcess: ChildProcess

            Returns void

      Returns void

    • Emitted when a child process has an error when spawning

      Parameters

      • event: "startError"
      • listener: (err: Error) => void
          • (err: Error): void
          • Parameters

            • err: Error

            Returns void

      Returns void

    • Emitted when an internal consistency check fails

      Parameters

      • event: "internalError"
      • listener: (err: Error) => void
          • (err: Error): void
          • Parameters

            • err: Error

            Returns void

      Returns void

    • Emitted when tasks receive data, which may be partial chunks from the task stream.

      Parameters

      • event: "taskData"
      • listener: (data: string | Buffer, task: undefined | Task<any>) => void
          • (data: string | Buffer, task: undefined | Task<any>): void
          • Parameters

            • data: string | Buffer
            • task: undefined | Task<any>

            Returns void

      Returns void

    • Emitted when a task has been resolved

      Parameters

      • event: "taskResolved"
      • listener: (task: Task<any>, proc: BatchProcess) => void
          • (task: Task<any>, proc: BatchProcess): void
          • Parameters

            • task: Task<any>
            • proc: BatchProcess

            Returns void

      Returns void

    • Emitted when a task has an error

      Parameters

      • event: "taskError"
      • listener: (err: Error, task: Task<any>, proc: BatchProcess) => void
          • (err: Error, task: Task<any>, proc: BatchProcess): void
          • Parameters

            • err: Error
            • task: Task<any>
            • proc: BatchProcess

            Returns void

      Returns void

    • Emitted when a process fails health checks

      Parameters

      • event: "healthCheckError"
      • listener: (err: Error, proc: BatchProcess) => void
          • (err: Error, proc: BatchProcess): void
          • Parameters

            • err: Error
            • proc: BatchProcess

            Returns void

      Returns void

    • Emitted when a child process has an error during shutdown

      Parameters

      • event: "endError"
      • listener: (err: Error) => void
          • (err: Error): void
          • Parameters

            • err: Error

            Returns void

      Returns void

    • Emitted when this instance is in the process of ending.

      Parameters

      • event: "beforeEnd"
      • listener: () => void
          • (): void
          • Returns void

      Returns void

    • Emitted when this instance has ended. No child processes should remain at this point.

      Parameters

      • event: "end"
      • listener: () => void
          • (): void
          • Returns void

      Returns void

Accessors

  • get busyProcs(): number
  • Returns number

    the current number of child processes currently servicing tasks

  • get ended(): boolean
  • get pendingTasks(): number
  • Returns number

    the number of pending (not currently worked on) tasks

  • get pids(): Promise<number[]>
  • Returns Promise<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

  • childEndCounts(): { broken: number; closed: number; dead: number; ending: number; idle: number; old: number; timeout: number; tooMany: number; unhealthy: number; worn: number }
  • Returns { broken: number; closed: number; dead: number; ending: number; idle: number; old: number; timeout: number; tooMany: number; unhealthy: number; worn: number }

    report why child processes were recycled

    • broken: number
    • closed: number
    • dead: number
    • ending: number
    • idle: number
    • old: number
    • timeout: number
    • tooMany: number
    • unhealthy: number
    • worn: number
  • deleteAllTags(file: string): 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

    Returns Promise<void>

  • end(gracefully?: boolean): Promise<void>
  • 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>

  • extractBinaryTag(tagname: string, src: string, dest: string): Promise<void>
  • 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

    • tagname: string
    • src: string
    • dest: string

    Returns Promise<void>

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

  • extractBinaryTagToBuffer(tagname: string, imageFile: string): Promise<Buffer>
  • 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

    • tagname: string
    • imageFile: string

    Returns Promise<Buffer>

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

  • extractJpgFromRaw(imageFile: string, outputFile: string): Promise<void>
  • 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

    • imageFile: string
    • outputFile: string

    Returns Promise<void>

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

  • extractPreview(imageFile: string, previewFile: string): Promise<void>
  • 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

    • imageFile: string
    • previewFile: string

    Returns Promise<void>

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

  • extractThumbnail(imageFile: string, thumbnailFile: string): Promise<void>
  • 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

    • imageFile: string
    • thumbnailFile: string

    Returns Promise<void>

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

  • read<T>(file: string, args?: string[]): Promise<T>
  • Read the tags in file.

    memberof

    ExifTool

    Type parameters

    Parameters

    • file: string

      the file to extract metadata tags from

    • args: string[] = ...

    Returns Promise<T>

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

  • readRaw(file: string, args: string[]): Promise<Tags>
  • 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).

    see

    https://github.com/photostructure/exiftool-vendored.js/issues/44

    Parameters

    • file: string
    • args: string[]

      all ExifTool arguments, except for the file path. If -charset or filename=utf8 are missing, and you have non-ascii tag values, you're going to have a bad day. The resolved pathname will be appended to the args array for you, and if -json is missing from args, that will be prepended, as it's a prerequisite to parsing the result.

    Returns Promise<Tags>

    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 return value is wholly untyped.

  • rewriteAllTags(inputFile: string, outputFile: string, allowMakerNoteRepair?: boolean): Promise<void>
  • 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 {@link .read()}.

    see

    https://exiftool.org/faq.html#Q20

    Parameters

    • inputFile: string

      the path to the problematic image

    • outputFile: string

      the path to write the repaired image

    • allowMakerNoteRepair: boolean = false

      if there are problems with MakerNote tags, allow ExifTool to apply heuristics to recover corrupt tags. See exiftool's -F flag.

    Returns Promise<void>

    resolved when outputFile has been written.

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

    a promise holding the version number of the vendored ExifTool

  • write<T>(file: string, tags: T, args?: string[]): Promise<void>
  • Write the given tags to file.

    memberof

    ExifTool

    Type parameters

    Parameters

    • file: string

      an existing file to write tags to.

    • tags: T

      the tags to write to file.

    • Optional args: string[]

    Returns Promise<void>

    Either the promise will be resolved if the tags are written to successfully, or the promise will be rejected if there are errors or warnings.

Generated using TypeDoc