mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix: Ensure resizeImage's canvas has at least 1px of width and height (#2409)
* ensure resizeImage canvas has > 0 width, height * add tests for sliver background images
This commit is contained in:
@ -541,8 +541,8 @@ export class CanvasRenderer {
|
||||
}
|
||||
|
||||
const canvas = (this.canvas.ownerDocument as Document).createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
canvas.width = Math.max(1, width);
|
||||
canvas.height = Math.max(1, height);
|
||||
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, width, height);
|
||||
return canvas;
|
||||
|
Reference in New Issue
Block a user