Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canvas toBlob is not recognized as a function in safari

I am able to download an image in Chrome & Firefox using the code below but in Safari it's throwing this error:

TypeError: 'undefined' is not a function (evaluating 'canvas.toBlob(blobCallback('wallpaperdeae'))')

$("#save").click(function(){

   function blobCallback(iconName) {
        return function (b) {

            var a = document.getElementById('download');
            a.download = iconName + ".jpg";
            a.href = window.URL.createObjectURL(b);
        }
    }
    canvas.toBlob(blobCallback('wallpaperdeae'));

});
like image 251
Bikshu s Avatar asked Oct 20 '25 09:10

Bikshu s


1 Answers

I don't think the toBlob method is supported in Safari:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#Browser_compatibility

According to this it's only available in Chrome 50+ and Firefox (19+ for basic support and 25+ for Image quality parameter) with some basic support in IE 10 and above.

So there's no support whatsoever for Safari.

Edit: According to the referenced URL support was added for the toBlob method in Safari 11 which came out on September 19th 2017

like image 144
DibsyJr Avatar answered Oct 21 '25 23:10

DibsyJr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!