Function maskToEditMask

  • Combine one or more segmentation masks into a single mask Buffer suitable for editImage()'s mask input (white = edit region, black = keep).

    Parameters

    • masks: SegmentMask | SegmentMask[]

      one mask or many (unioned)

    • opts: {
          target?: "object" | "background";
          width?: number;
          height?: number;
      } = {}
      • Optional target?: "object" | "background"

        'object' (default) edits the masked object; 'background' inverts so everything except the object is edited.

      • Optional width?: number

        optional canvas width; defaults to the first mask's.

      • Optional height?: number

        optional canvas height; defaults to the first mask's.

    Returns Promise<Buffer>