我想用HTML5 Canvas调整从客户端iOS相机拍摄的图像的大小,但是我继续在这个奇怪的错误中运行,如果大于〜1.5mb,图像的比例错误
它适用于桌面,但不适用于带有媒体上传API的最新iOS版本.
你可以在这里看到一个例子:http://jsbin.com/ekuros/1
知道怎么解决这个问题吗?这是内存问题吗?
$('#file').on('change', function (e) {
var file = e.currentTarget.files[0];
var reader = new FileReader();
reader.onload = function (e) {
var image = $('<img/>');
image.on('load', function () {
var square = 320;
var canvas = document.createElement('canvas');
canvas.width = square;
canvas.height = square;
var context = canvas.getContext('2d');
context.clearRect(0, 0, square, square);
var imageWidth;
var imageHeight;
var offsetX = 0;
var offsetY = 0;
if (this.width > this.height) {
imageWidth = Math.round(square * this.width / this.height); …Run Code Online (Sandbox Code Playgroud)