Changes the canvas size
npm install canvas-image-resize- Imports
canvas-image-resize.
For ES Modules:
import { resize } from "canvas-image-resize";For CommonJS:
const { resize } = require("canvas-image-resize");- Example of use.
resize({ canvas, options: { width: 640 } });or
const { resizedCanvas } = resize({ canvas, options: { width: 640 } });resize({ canvas, options })
Canvas
- canvas : HTMLCanvasElement - An html5 canvas element to resize and draw from
Options
- height : number - New height of the canvas ex: 300
- width : number - New width of the canvas ex: 400
- keepAspectRatio : boolean - Flag to maintain proportions. Default: true
- imageSmoothingQuality : "low" | "medium" | "high" - Image smoothing quality. Default: "high"
- contextType : "2d" - Canvas context type. Default: "2d"
Return object
- resizedCanvas : HTMLCanvasElement
MIT

