Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Canvas

Index

Constructors

  • new Canvas(width: number, height: number, type?: "image" | "pdf" | "svg"): Canvas
  • Parameters

    • width: number
    • height: number
    • Optional type: "image" | "pdf" | "svg"

    Returns Canvas

Properties

PNG_ALL_FILTERS: number

Constant used in PNG encoding methods.

PNG_FILTER_AVG: number

Constant used in PNG encoding methods.

PNG_FILTER_NONE: number

Constant used in PNG encoding methods.

PNG_FILTER_PAETH: number

Constant used in PNG encoding methods.

PNG_FILTER_SUB: number

Constant used in PNG encoding methods.

PNG_FILTER_UP: number

Constant used in PNG encoding methods.

PNG_NO_FILTERS: number

Constant used in PNG encoding methods.

height: number
stride: number

Non standard. Getter. The stride used by the canvas.

type: "image" | "pdf" | "svg"

Non standard. The type of the canvas.

width: number

Methods

  • createJPEGStream(config?: JpegConfig): JPEGStream
  • Parameters

    • Optional config: JpegConfig

    Returns JPEGStream

  • createPDFStream(config?: PdfConfig): PDFStream
  • Parameters

    • Optional config: PdfConfig

    Returns PDFStream

  • createPNGStream(config?: PngConfig): PNGStream
  • Parameters

    • Optional config: PngConfig

    Returns PNGStream

  • getContext(contextId: "2d", contextAttributes?: NodeCanvasRenderingContext2DSettings): NodeCanvasRenderingContext2D
  • Parameters

    • contextId: "2d"
    • Optional contextAttributes: NodeCanvasRenderingContext2DSettings

    Returns NodeCanvasRenderingContext2D

  • toBuffer(cb: (err: null | Error, result: Buffer) => void): void
  • toBuffer(cb: (err: null | Error, result: Buffer) => void, mimeType: "image/png", config?: PngConfig): void
  • toBuffer(cb: (err: null | Error, result: Buffer) => void, mimeType: "image/jpeg", config?: JpegConfig): void
  • toBuffer(): Buffer
  • toBuffer(mimeType: "image/png", config?: PngConfig): Buffer
  • toBuffer(mimeType: "image/jpeg", config?: JpegConfig): Buffer
  • toBuffer(mimeType: "application/pdf", config?: PdfConfig): Buffer
  • toBuffer(mimeType: "raw"): Buffer
  • For image canvases, encodes the canvas as a PNG. For PDF canvases, encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an SVG.

    Parameters

    • cb: (err: null | Error, result: Buffer) => void
        • (err: null | Error, result: Buffer): void
        • Parameters

          • err: null | Error
          • result: Buffer

          Returns void

    Returns void

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • cb: (err: null | Error, result: Buffer) => void
        • (err: null | Error, result: Buffer): void
        • Parameters

          • err: null | Error
          • result: Buffer

          Returns void

    • mimeType: "image/png"
    • Optional config: PngConfig

    Returns void

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • cb: (err: null | Error, result: Buffer) => void
        • (err: null | Error, result: Buffer): void
        • Parameters

          • err: null | Error
          • result: Buffer

          Returns void

    • mimeType: "image/jpeg"
    • Optional config: JpegConfig

    Returns void

  • For image canvases, encodes the canvas as a PNG. For PDF canvases, encodes the canvas as a PDF. For SVG canvases, encodes the canvas as an SVG.

    Returns Buffer

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • mimeType: "image/png"
    • Optional config: PngConfig

    Returns Buffer

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • mimeType: "image/jpeg"
    • Optional config: JpegConfig

    Returns Buffer

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • mimeType: "application/pdf"
    • Optional config: PdfConfig

    Returns Buffer

  • Returns the unencoded pixel data, top-to-bottom. On little-endian (most) systems, the array will be ordered BGRA; on big-endian systems, it will be ARGB.

    Parameters

    • mimeType: "raw"

    Returns Buffer

  • toDataURL(): string
  • toDataURL(mimeType: "image/png"): string
  • toDataURL(mimeType: "image/jpeg", quality?: number): string
  • toDataURL(cb: (err: null | Error, result: string) => void): void
  • toDataURL(mimeType: "image/png", cb: (err: null | Error, result: string) => void): void
  • toDataURL(mimeType: "image/jpeg", cb: (err: null | Error, result: string) => void): void
  • toDataURL(mimeType: "image/jpeg", config: JpegConfig, cb: (err: null | Error, result: string) => void): void
  • toDataURL(mimeType: "image/jpeg", quality: number, cb: (err: null | Error, result: string) => void): void
  • Defaults to PNG image.

    Returns string

  • Non-standard.

    Parameters

    • mimeType: "image/png"

    Returns string

  • Non-standard.

    Parameters

    • mimeType: "image/jpeg"
    • Optional quality: number

    Returns string

  • Non-standard. Defaults to PNG image.

    Parameters

    • cb: (err: null | Error, result: string) => void
        • (err: null | Error, result: string): void
        • Parameters

          • err: null | Error
          • result: string

          Returns void

    Returns void

  • Non-standard.

    Parameters

    • mimeType: "image/png"
    • cb: (err: null | Error, result: string) => void
        • (err: null | Error, result: string): void
        • Parameters

          • err: null | Error
          • result: string

          Returns void

    Returns void

  • Non-standard.

    Parameters

    • mimeType: "image/jpeg"
    • cb: (err: null | Error, result: string) => void
        • (err: null | Error, result: string): void
        • Parameters

          • err: null | Error
          • result: string

          Returns void

    Returns void

  • Non-standard.

    Parameters

    • mimeType: "image/jpeg"
    • config: JpegConfig
    • cb: (err: null | Error, result: string) => void
        • (err: null | Error, result: string): void
        • Parameters

          • err: null | Error
          • result: string

          Returns void

    Returns void

  • Non-standard.

    Parameters

    • mimeType: "image/jpeg"
    • quality: number
    • cb: (err: null | Error, result: string) => void
        • (err: null | Error, result: string): void
        • Parameters

          • err: null | Error
          • result: string

          Returns void

    Returns void

Generated using TypeDoc