mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix check image with 0 width or height
This commit is contained in:
parent
190c7b63ee
commit
4970be9d4c
@ -595,13 +595,10 @@ export class CanvasRenderer extends Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
let widthTmp = Math.max(1, image.width);
|
|
||||||
let heightTmp = Math.max(1, image.height);
|
|
||||||
|
|
||||||
const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [
|
const [path, x, y, width, height] = calculateBackgroundRendering(container, index, [
|
||||||
widthTmp,
|
image.width,
|
||||||
heightTmp,
|
image.height,
|
||||||
widthTmp / heightTmp
|
image.width / image.height
|
||||||
]);
|
]);
|
||||||
const pattern = this.ctx.createPattern(
|
const pattern = this.ctx.createPattern(
|
||||||
this.resizeImage(image, width, height),
|
this.resizeImage(image, width, height),
|
||||||
@ -614,8 +611,8 @@ export class CanvasRenderer extends Renderer {
|
|||||||
const [lineLength, x0, x1, y0, y1] = calculateGradientDirection(backgroundImage.angle, width, height);
|
const [lineLength, x0, x1, y0, y1] = calculateGradientDirection(backgroundImage.angle, width, height);
|
||||||
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = width;
|
canvas.width = Math.max(1, width);
|
||||||
canvas.height = height;
|
canvas.height = Math.max(1, height);
|
||||||
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
||||||
const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
|
const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user