Is there an easy way to detect if a browser can render HEIC image?
I can think of one way, render a pixel heic image and check the color of the pixel post render. Something like:
const myImg = new Image();
myImg.crossOrigin = "Anonymous";
myImg.onload = () => {
const context = document.createElement('canvas').getContext('2d');
context.drawImage(myImg, 0, 0);
const {
data
} = context.getImageData(10, 10, 1, 1);
console.log(data)
}
myImg.src = 'https://picsum.photos/200/300';
Wondering, if there is a better way?
2
Answers
Using image.decode seems to work. I can’t test since I don’t Safari