Maximum size of a element

后端 未结 14 1915
粉色の甜心
粉色の甜心 2020-11-22 07:34

I\'m working with a canvas element with a height of 600 to 1000 pixels and a width of several tens or hundreds of thousands of pixels. However, aft

14条回答
  •  执念已碎
    2020-11-22 08:03

    iOS has different limits.

    Using the iOS 7 simulator I was able to demonstrate the limit is 5MB like this:

    var canvas = document.createElement('canvas');
    canvas.width = 1024 * 5;
    canvas.height = 1024;
    alert(canvas.toDataURL('image/jpeg').length);
    // prints "110087" - the expected length of the dataURL
    

    but if I nudge the canvas size up by a single row of pixels:

    var canvas = document.createElement('canvas');
    canvas.width = 1024 * 5;
    canvas.height = 1025;
    alert(canvas.toDataURL('image/jpeg'));
    // prints "data:," - a broken dataURL
    

提交回复
热议问题