Options
All
  • Public
  • Public/Protected
  • All
Menu

Class File

A thin layer on top of cv.Mat with lots of utilities to load, write, encode, etc.

Hierarchy

  • File

Index

Constructors

constructor

  • new File(name: string, _mat: Mat): File

Properties

Protected _mat

_mat: Mat

name

name: string

Accessors

height

  • get height(): number

mat

  • get mat(): Mat

width

  • get width(): number

Methods

asArrayBuffer

  • asArrayBuffer(format?: string): Promise<ArrayBuffer>
  • Returns an array buffer containing the image encoded in given format or inferring format from its name.

    Parameters

    • Default value format: string = this.getExtension()

    Returns Promise<ArrayBuffer>

asBase64

  • asBase64(format?: string): Promise<string>
  • Parameters

    • Default value format: string = this.getExtension()

    Returns Promise<string>

asDataUrl

  • asDataUrl(): string

asHTMLImageData

  • asHTMLImageData(): ImageData

asImageData

  • asImageData(): CVImageData

asMat

clone

  • clone(name?: string): File
  • Parameters

    • Default value name: string = this.name

    Returns File

delete

  • delete(): void

getExtension

  • getExtension(): string

getMimeType

  • getMimeType(): undefined | string
  • Returns undefined | string

remove

  • remove(deleteMat?: boolean): this
  • It removes the the file from file system and also delete() this file's Mat

    Parameters

    • Default value deleteMat: boolean = true

    Returns this

setMat

  • setMat(mat: Mat): this

show

  • show(el: HTMLElement): this
  • Shows this image in given HTML canvas or image element.

    Parameters

    • el: HTMLElement

    Returns this

size

  • size(): object
  • Returns object

    • height: number
    • width: number

toRgba

  • toRgba(): this
  • Converts the Mat of this file to RGBA channel type. It will replace the current mat and delete the original.

    Returns this

toString

  • toString(): string

write

  • write(path?: string, format?: string): Promise<this>
  • Writes this image on given file path, encoded in given format (or inferred form current name).

    Parameters

    • Default value path: string = this.name
    • Default value format: string = this.getExtension()

    Returns Promise<this>

Static Private _buildName

  • _buildName(name: string | undefined): string
  • Parameters

    • name: string | undefined

    Returns string

Static asPath

  • asPath(f: string | File): string

Static fileType

  • fileType(a: ArrayBuffer): undefined | FileTypeResult
  • Parameters

    • a: ArrayBuffer

    Returns undefined | FileTypeResult

Static fromArrayBuffer

  • fromArrayBuffer(buffer: ArrayBuffer, name?: undefined | string): Promise<File>
  • Loads file from given array buffer containing an encoded image.

    Parameters

    • buffer: ArrayBuffer
    • Optional name: undefined | string

    Returns Promise<File>

Static fromArrayBufferView

  • fromArrayBufferView(a: ArrayBufferView, name?: undefined | string): Promise<File>
  • Loads file from given array buffer view containing an encoded image.

    Parameters

    • a: ArrayBufferView
    • Optional name: undefined | string

    Returns Promise<File>

Static fromBase64

  • fromBase64(base64: string, name?: undefined | string): Promise<File>
  • Loads file from given base64 string containing an encoded image.

    Parameters

    • base64: string
    • Optional name: undefined | string

    Returns Promise<File>

Static fromCanvas

  • fromCanvas(el: HTMLElement | string): File
  • Loads file form existing HTMLElement or HTMLImageElement

    Parameters

    • el: HTMLElement | string

    Returns File

Static fromData

  • fromData(data: CVImageData, name?: undefined | string): File
  • Parameters

    • data: CVImageData
    • Optional name: undefined | string

    Returns File

Static fromDataUrl

  • fromDataUrl(dataUrl: string, name?: undefined | string): Promise<File>
  • Loads file from given data url string containing an encoded image.

    Parameters

    • dataUrl: string
    • Optional name: undefined | string

    Returns Promise<File>

Static fromFile

  • fromFile(path: string, name?: string): Promise<File>
  • Parameters

    • path: string
    • Default value name: string = basename(path)

    Returns Promise<File>

Static fromHtmlFileInputElement

  • fromHtmlFileInputElement(el: HTMLInputElement): Promise<File[]>
  • Loads files from files in html input element of type "file".

    Parameters

    • el: HTMLInputElement

    Returns Promise<File[]>

Static fromMat

  • fromMat(mat: Mat, name?: undefined | string): File
  • Parameters

    • mat: Mat
    • Optional name: undefined | string

    Returns File

Static fromUrl

  • fromUrl(url: string, o?: RequestInit & object): Promise<File>
  • Parameters

    • url: string
    • Default value o: RequestInit & object = {}

    Returns Promise<File>

Static getBufferFileName

  • getBufferFileName(a: ArrayBuffer): string
  • Parameters

    • a: ArrayBuffer

    Returns string

Static getBufferFileType

  • getBufferFileType(a: ArrayBuffer): FileTypeResult
  • Parameters

    • a: ArrayBuffer

    Returns FileTypeResult

Static isFile

  • isFile(f: any): boolean
  • Parameters

    • f: any

    Returns boolean

Static resolve

  • resolve(files: string | File | undefined | (undefined | string | File)[]): Promise<File[]>
  • Given paths, urls or files it will try to load them all and return a list of File for those succeed.

    Parameters

    • files: string | File | undefined | (undefined | string | File)[]

    Returns Promise<File[]>

Static resolveOne

  • resolveOne(files: string | File | undefined | (undefined | string | File)[]): Promise<undefined | File>
  • Shortcut for [resolve] that returns the first result.

    Parameters

    • files: string | File | undefined | (undefined | string | File)[]

    Returns Promise<undefined | File>

Generated using TypeDoc