admin管理员组文章数量:1432360
I'm trying to reduce images in client side before uploading them to preserve users' bandwidth and storage space in server side, while keeping informations about the original shot.
Current process flow : fileReader -> canvas (drawImage) -> base64 -> XMLHttpRequest (to get progress) -> php server
One drawback of this technique is loss of metadata (Exif), such as date and time, position, orientation...
Extracting exif datas can be done via Exif JS or other library. But I didn't find how to put these informations in the reduced file (in canvas object, base64 url or php side).
Any idea or path to follow ?
I'm trying to reduce images in client side before uploading them to preserve users' bandwidth and storage space in server side, while keeping informations about the original shot.
Current process flow : fileReader -> canvas (drawImage) -> base64 -> XMLHttpRequest (to get progress) -> php server
One drawback of this technique is loss of metadata (Exif), such as date and time, position, orientation...
Extracting exif datas can be done via Exif JS or other library. But I didn't find how to put these informations in the reduced file (in canvas object, base64 url or php side).
Any idea or path to follow ?
Share Improve this question asked Jun 9, 2015 at 8:54 cocotococoto 431 silver badge6 bronze badges1 Answer
Reset to default 4There is no easy way to do this. Canvas will only save out the JPEG file, then encode it as either a Data-URL or a Blob depending on the method you chose with the most basic chunks. There is no mechanism to insert custom or additional chunks into the file format from the browser-side of things.
To put back the EXIF information you would have to do:
- Decode the Data-URI or convert the blob, both to ArrayBuffer
- Parse the buffer manually to map the markers
- Create a new buffer large enough to hold the produced JPEG file plus the EXIF data
- Insert the EXIF data
- Append image data etc. according the file format
Now you can wrap it as a Blob object or convert it back to a Data-URL. It's possible to do but not just straight forward. The file format specification will be necessary.
An optional, and perhaps better approach in this case, would be to extract the EXIF chunk, format it as a JSON object and send that as meta-data to the server. You just need to make server side "aware" of that it need to consider the meta-data for the image received.
本文标签: javascriptAdd metadata (Exif) to base64Stack Overflow
版权声明:本文标题:javascript - Add metadata (Exif) to base64 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745601743a2665606.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论