imgoji
    Preparing search index...

    Class Encoder

    Encodes an image as an imgoji codec string: grows a breadth-first quadtree, selects/blends a glyph per cell, prunes by BFOS cost-complexity to a byte budget, and emits a position-implicit RLE-compressed string. Heavy: builds a glyph atlas and matches per cell. The display-only Renderer does not import this.

    Index
    • Encode an image as an imgoji codec string (BFOS-pruned blended quadtree).

      Parameters

      • source: CanvasImageSource

        the image (cover-fit to 256²).

      • Optionalopts: {
            alpha?: number;
            bilateral?: number;
            byteTarget?: number;
            compare?: number;
            depth?: number;
            detailGate?: number;
            metric?: "cielab" | "oklab";
            seed?: string;
            skipBias?: number;
            threshold?: number;
        } = {}
        • Optionalalpha?: number

          per-layer blend weight (must match the viewer's alpha).

        • Optionalbilateral?: number

          edge-preserving smoothing sigmaR applied to the match target.

        • OptionalbyteTarget?: number

          deflated-byte budget; the prune threshold is binary-searched to hit it.

        • Optionalcompare?: number

          comparison/match resolution.

        • Optionaldepth?: number

          max quadtree depth (8 = one pixel per cell at 256²).

        • OptionaldetailGate?: number

          Sobel gate; cells below it stay leaves.

        • Optionalmetric?: "cielab" | "oklab"

          matcher color space.

        • Optionalseed?: string

          DSL seed string (base-layer sprites / anchor pins).

        • OptionalskipBias?: number

          paint-vs-background-skip bias.

        • Optionalthreshold?: number

          fixed prune threshold (0..150) overriding byteTarget; lambda = 10^(threshold/25).

      Returns Promise<
          {
              bytes: number;
              de00: number;
              deflatedBytes: number;
              depthCounts: number[];
              lambda: number;
              recon: ImageData;
              string: string;
              threshold: number;
              tokens: number;
          },
      >

    • Flatten the image into a grid of opaque emoji (one per cell) for terminals / chat, with optional semantic overrides. No quadtree.

      Parameters

      • source: CanvasImageSource

        the image.

      • Optionalopts: {
            blank?: "dark" | "light";
            boost?: Function;
            cols?: number;
            lambda?: number;
            rows?: number;
        } = {}
        • Optionalblank?: "dark" | "light"

          blank the matching background anchor to a space.

        • Optionalboost?: Function

          (x0,y0,x1,y1) => Map<emoji, 0..1> semantic distance per cell.

        • Optionalcols?: number

          columns.

        • Optionallambda?: number

          color/semantic blend weight (0 = color only).

        • Optionalrows?: number

          rows (rows = cols / line-height for square paste).

      Returns Promise<{ cols: number; grid: string; rows: number }>