mobile safari image upload & their sizes

时间:2022-10-31 10:20:26

Ok so as many of know, safari mobile now allows file uploads through camera or image library.

好吧,因为很多人都知道,safari mobile现在允许通过相机或图像库上传文件。

The 'problem' is that when the picture is taken from the camera, it is sent as it is, meaning it is very heavy in memory (I think it's around 2 or 3 mb even on iphone 4).

“问题”是当从相机拍摄照片时,它会按原样发送,这意味着它的内存非常重(我认为即使在iphone 4上也是2或3 mb)。

This makes the upload really slow and also bandwidth consuming (not good for mobile). Do you know if, with the <file /> html tag, there is a way to say to iOS: "hey, can you also compress the picture a bit?" - like it's being done when said images are sent via the mail app.

这使得上传速度非常慢并且带宽消耗(对移动设备不利)。你是否知道,使用 html标签,是否有办法对iOS说:“嘿,你还可以压缩图片吗?” - 就像通过邮件应用程序发送所述图像一样。

Thanks in advance.

提前致谢。

2 个解决方案

#1


10  

There's a library for that: https://github.com/gokercebeci/canvasResize

有一个库:https://github.com/gokercebeci/canvasResize

It works by putting the image to a <canvas /> (smaller than original image), then getting the image data so you can post it to your server.

它的工作原理是将图像放到 (小于原始图像),然后获取图像数据,以便将其发布到服务器。

#2


2  

I don't think you can actually do anything there. What you can do though is use the FILE API and slice the upload in smaller chunks, reducing the memory overload.

我认为你不能在那里做任何事情。你可以做的是使用FILE API并以较小的块切片上传,减少内存过载。

Here is an excellent post on how to do this:

这是一篇关于如何做到这一点的优秀文章:

http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files

http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files

#1


10  

There's a library for that: https://github.com/gokercebeci/canvasResize

有一个库:https://github.com/gokercebeci/canvasResize

It works by putting the image to a <canvas /> (smaller than original image), then getting the image data so you can post it to your server.

它的工作原理是将图像放到 (小于原始图像),然后获取图像数据,以便将其发布到服务器。

#2


2  

I don't think you can actually do anything there. What you can do though is use the FILE API and slice the upload in smaller chunks, reducing the memory overload.

我认为你不能在那里做任何事情。你可以做的是使用FILE API并以较小的块切片上传,减少内存过载。

Here is an excellent post on how to do this:

这是一篇关于如何做到这一点的优秀文章:

http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files

http://www.html5rocks.com/en/tutorials/file/dndfiles/#toc-slicing-files