I'm trying to show Tiff File in browser, i successfully read Tiff using UTIF.js file, Where I am using Web worker to read Tiff format file . Some files are very large like 10,000 px height and 13,000 width, I need to show them in browser. Browser crashes while executing code OffscreenCanvas.convertToBlob method which return Promise object.
This is where i used Web Worker and Offscreencanvas , I have tried convertToBlob method with different parameter such as quality .6 and less also but still browser crashing.
UTIF.decodeImage(ubuf,utif[k]);
var ubuf1 =UTIF.toRGBA8(utif[k]);
var a = new Uint8ClampedArray(ubuf1);
var imgData = new ImageData(a,utif[k].width,utif[k].height);
var canvas1 = new OffscreenCanvas(utif[k].width,utif[k].height);
var ctx = canvas1.getContext('2d');
ctx.putImageData(imgData,0,0);
var that = self;
if(utif[k].width >2048) {
canvas1.convertToBlob({type : "image/jpeg",
quality : 0.3
}).then(function(blob) {
that.postMessage(blob);
});
}
else {
canvas1.convertToBlob(
{type : "image/jpeg",
quality : 1
}).then(function(blob) {
that.postMessage(blob);
});
}
I am expecting browser should not crashes in large file scenario.
THanks a Lot in Advance.
Aucun commentaire:
Enregistrer un commentaire