Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove EXIF data from image 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 with c.toDataURL().

So my question how do I remove EXIF data using javascript?

like image 675
einstein Avatar asked Nov 05 '13 14:11

einstein


People also ask

Can EXIF data be deleted?

You do have the option to view EXIF data but the only item you can remove is location data. To remove the remaining data, you'll need to use a third-party app such as ImageOptim. To remove location data, open the image in Preview, select Tools > Show Inspector, and click the information (i) tab.

Can you manipulate EXIF data?

Paid standard programs such as Adobe Lightroom (Mac and Windows), Apple Photos (Mac) and Aperture (Mac) can help you edit the meta information. The free software GIMP now also supports the modification of Exif information. You can access the image metadata simply by opening an image or photo from the Image tab.

Does SMS remove EXIF data?

Messages does not strip this data from the images it sends. The safer alternative is to use a different messaging platform to share photos—iPhone users have exactly the same issue with iMessage.


1 Answers

Note, 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
like image 149
Pinal Avatar answered Oct 11 '22 10:10

Pinal