画布绘制图像问题,导致白色,仅某些图像



尝试使用画布绘制图像。如果使用此图像会导致白色,如果使用其他图像,则效果良好。请开导我。有什么吗[1] :https://i.stack.imgur.com/TesBY.jpg(如果你放大,它会显示图像…(

const img = document.createElement('img');
img.src = reader.result;
img.onload = () => {
const canvas = document.createElement('canvas');
canvas.width = img.width
canvas.height = img.height
const ctx = canvas.getContext('2d');

ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

canvas.toBlob(resolve);
};
};

找到了一个解决方法,在将图像处理为图形之前,执行图像转换,猜测它将修复损坏的图像。。。我终于这样解决了。

从"图像转换"导入*作为图像转换;

let compressIm = new Promise(resolve => {imageConversion.compress(imgObj,{
quality: 1,
type: "image/jpeg",
width: 800,
height: 600,
orientation:2,
scale: 0.5,
})
})

最新更新