I'm using konva 7.0.6 in an angular 12 app. When trying to render a jpg image via a URL, when the image is large around 7MB or greater, the image loading and rendering is taking long. Whereas when opening the image URL in a browser tab it is loading and rendering faster.
I'm using the below code to load the image
return new Observable((observer) => {
const img = new Image();
this.imageObject = img;
img.crossOrigin = 'anonymous';
img.src = imageUrl;
img.onload = (event) => {
const loadedImage: any = event.currentTarget;
img.width = loadedImage.width;
img.height = loadedImage.height;
observer.next(img);
observer.complete();
};
});
And then creating a konva Image object with the image
this.imageShape = new konvaImage({
x: 0,
y: 0,
name: 'img',
image: response,
draggable: false,
width: this.imageWidth,
height: this.imageHeight
});
this.imageShape.cache();
this.layer.add(this.imageShape);
Is there any better method I can use to reduce the load time of the image rendering on the canvas?