hMatoba / piexifjs

Read and modify exif in client-side or server-side JavaScript.
MIT License
573 stars 118 forks source link

TypeError: Cannot use 'in' operator to search for '0th' in data:image... #56

Closed Arxcis closed 6 years ago

Arxcis commented 6 years ago

Code failing

let exifBytes = piexifjs.dump(dataURL);

Error message

TypeError: Cannot use 'in' operator to search for '0th' in data:image...

Environment Chrome 70 Vue 3.1.0 cmd vue-cli-service serve --watch "piexifjs": "^1.0.4",

MDN Related error https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/in_operator_no_object

Nobody else get this error? Fixed in piexif 2.0 ? Scanning through the source codes I can see that the in operator is used everywhere.

hMatoba commented 6 years ago

https://github.com/hMatoba/piexifjs#how-to-use

Arxcis commented 6 years ago

Ah of course! Thank you very much :+1:

Solution DON'T pass dataurl as agrument to piexifjs.dump. It takes an exifojb as argument, which is returned from the piexifjs.load.

Example of correct usage

let exifojb = piexifjs.load(dataurl);
let exifstr = piexifjs.dump(exifobj);