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:
Chang Wang
2021-07-04 01:40:25 -04:00
committed by GitHub
parent b09ee30dae
commit bb9237155c
3 changed files with 9 additions and 2 deletions

View File

@ -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;