admin管理员组文章数量:1405294
I read in a file from an HTML file input. For iOS I can take a picture from the camera. The problem is that if you take the picture with the camera the content will include EXIF data(at least if I read the file content with the FileReader API).
I can't use canvas cropping if the image includes EXIF data. Because the image get destroyed every time I call
.toDataURL()
. My guess is it doesn't recognize EXIF data and don't know how to crop a image with EXIF data.The file content is being base64 encoded by
FileReader.readAsDataURL()
. And I insert it into img.src.The cropping is done by drawing a new image with
ctx.drawImage(...)
based in the old image and I finally got the new image data withc.toDataURL()
.
So my question how do I remove EXIF data using javascript?
I read in a file from an HTML file input. For iOS I can take a picture from the camera. The problem is that if you take the picture with the camera the content will include EXIF data(at least if I read the file content with the FileReader API).
I can't use canvas cropping if the image includes EXIF data. Because the image get destroyed every time I call
.toDataURL()
. My guess is it doesn't recognize EXIF data and don't know how to crop a image with EXIF data.The file content is being base64 encoded by
FileReader.readAsDataURL()
. And I insert it into img.src.The cropping is done by drawing a new image with
ctx.drawImage(...)
based in the old image and I finally got the new image data withc.toDataURL()
.
So my question how do I remove EXIF data using javascript?
Share Improve this question edited Nov 5, 2013 at 15:22 einstein asked Nov 5, 2013 at 14:37 einsteineinstein 13.9k29 gold badges86 silver badges110 bronze badges 3- 1 Maybe show how you are doing toDataUrl? I don't think canvas would have any issues with what you are doing. – David Nguyen Commented Nov 5, 2013 at 14:42
-
@Woho87 I'm assuming the original thing is a File or Blob that doesn't have a URL of it's own, right? Your issue may actually be caused by the importing into the canvas from the base64 url'd image, not exporting from it. Try
yourImgSrc = window.URL.createObjectURL(yourFile);
instead, then import that into the canvas. – Paul S. Commented Nov 5, 2013 at 16:41 - there should not be any exif in the canvas output... – dandavis Commented Jan 13, 2015 at 2:10
1 Answer
Reset to default 5 +25Note, you wrote:
the image get destroyed
I think that problem is not in EXIF data. I think you have the iOS canvas limitation:
The maximum size for a canvas element is 3 megapixels for devices with less than 256 MB RAM and 5 megapixels for devices with greater or equal than 256 MB RAM.
This limits don't throw any errors, so then you will try to render or read 6MB image you will get a broken blob/dataURL string and so on. And you will think that File API is broken, canvas methods toDataURL/toBlob are broken, and you will be right. But bugs aren't in browser, this is a system limitation.
There known libs that fix iOS limitations:
- Javascript-Load-Image
- ios-imagefile-megapixel
本文标签: iosHow to remove EXIF data from image using javascriptStack Overflow
版权声明:本文标题:ios - How to remove EXIF data from image using javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744319493a2600426.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论