Function imageBitmapToCanvas

  • Convert an image ImageBitmap or CanvasImageSource to a new canvas with a max width. Good for resizing images keeping the aspect ratio and generating previews.

    Parameters

    • bitmap: CanvasImageSource

      image to convert

    • maxWidth: number = 8192

      maximum width of the image (default: 8192). Images larger than this will be scaled down. This is because strings can get too long.

    • detachBitmap: boolean = false

      detach the bitmap after conversion (default: false). This will free up bitmap memory if you don't need it anymore.

      See also imageUrlToImageData, imageBitmapToBase64, imageBitmapToBlob

    Returns HTMLCanvasElement

Generated using TypeDoc