ExifReader
ExifReader copied to clipboard
Some photos have gps, some photos don't.
they were all taken from the same camera
one photo

another photo

what's wrong with me?
here is my code:
const tags = await ExifReader.load(arrbf, { expanded: true });
console.tron.log('tags', tags)
Hi! That's unfortunately how it is. Not all photos get a location recorded. My experience is that it's actually quite common that photos are missing GPS values. If you don't think this is the reason and you have a photo that has GPS in another Exif parser but not in ExifReader, please provide an example file and I'll have a look. Exiftool is a good program to check in. Here is an online version: http://exif.regex.info/exif.cgi
@mattiasw i try it on http://exif.regex.info/exif.cgi and even on your website https://mattiasw.github.io/ExifReader/amd/
it can still give data about gps. But in my code it only returns the data like this. It doesnt include gps information.
and with expaned: true param

That is weird. 🤔 Could it have something to do with React Native again? That the phone removes the location before using the photo or something. I've read that e.g. Iphone does that when uploading to a web site but not sure if it's the same in React Native.
https://apple.stackexchange.com/questions/326789/gps-exif-from-iphone-photo-upload-in-safari
When selecting images from the photo gallery on iOS I am able to get the EXIF data if I use another library that has native functionality. https://github.com/ivpusic/react-native-image-crop-picker/blob/356985acaaae425acf1ea7ad06910158420d907f/ios/src/ImageCropPicker.m
Search "includeExif" and you can see where it gets the exif data from the selected images.
However, with ExifReader I am not able to get the same EXIF data. I don't have a possible solution in mind but figured I'd leave you with the information in case you wanted to dig into it :)
base64ImageIos.txt Attached is the base64 data for the image I used in my screenshots below if you want to test against it.
When using the react-native-image-crop-picker here is what the EXIF data returned looks like. Notice it has lat/long/altitude

When using this library I do not get any of that information in the exif response.

EDIT: I don't think the issue has anything to do with your library, I believe there is some gypsy magic happening to obtain the EXIF data natively and it's not copying that to the output file. https://github.com/ivpusic/react-native-image-crop-picker/pull/1736
When searching the web regarding this I saw a lot of people having trouble getting the location data using regular Exif libraries and React Native. I think you're on to something here @tomgreco, you may have to use a native implementation to be able to read the location data from a photo. That's a bit sad if it's true but not much we can do about it I guess. Would be nice to know for sure though.
This issue is really a pain. Yes as @mattiasw say, using native solution it'll work, but there is some information I think it'll help (spend my whole day to found it 😢 ).
Using native solution with work on iOS and Android which have targetSDKVersion < 29
In Android with SDK >= 29, you need this permission:
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
Don't forget to request for this permission before you try to pick and read EXIF.
That's it, but...It's somehow funny that, on some device with different build of Android (Nokia, Samsung, Pixel...). Even with sdk > 29, you still can read EXIF easily without ACCESS_MEDIA_LOCATION. That's really a mess to support all version of Android. But to be sure, I think the solution i'v point out above is enough.
Hope it help. Read more here
Thank you for your research into this @kyoz! I know other developers will appreciate the time you put into this.
Thanks @mattiasw for great plugin. One more thing I just found out is that, also this permission is sensitive, but if you already granted permission for these (which we usually use to read and write image, mean scoped storage):
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
It will grant you ACCESS_MEDIA_LOCATION permission right away without any prompt 😆
I'm closing this since it seems there's not much to do for this library. But please keep commenting if anything new comes up. This discussion is linked from the README so people can find it.