我试图在将图像上传到服务器之前调整文件上传中图像的大小。我发现了decent plugin返回更新图像的blob,但是找不到如何将blob分配回上载所使用的文件对象。
Blob 看起来像:data:image / jpeg; base64,/ 9j / 4AAQSkZJRgABAQAAAQAB .....
var file = e.target.files[0];
canvasResize(file, {
width: 300,
height: 0,
crop: false,
quality: 80,
//rotate: 90,
callback: function (data, width, height) {
// How to assign the data blob back to the file?
//$(file).attr('src', data);
// THEN submit with the smaller photo
$('#PhotoForm').ajaxSubmit(options);
}
});
谢谢!
最佳答案
如果您仍然对canvasResize感到困惑,那么还有许多其他图像处理库。我以前使用Pixastic效果很好,尽管它的开销比canvasResize大。虽然是better documented。