cozy / cozy-photos-v2

Deprecated - New : https://github.com/cozy/cozy-drive/tree/master/src/photos - Personal Photo Gallery Manager
http://cozy.io
GNU Affero General Public License v3.0
27 stars 25 forks source link

Error extracting GPS data #177

Closed clochix closed 8 years ago

clochix commented 8 years ago

As reported by a user:

Importing a photo with GPS data throws this exception:

[TypeError: Cannot read property '6' of null]
TypeError: Cannot read property '6' of null
at gpsDegToDec (/usr/local/cozy/apps/photos/build/server/helpers/thumb.js:19:12)
at gm. (/usr/local/cozy/apps/photos/build/server/helpers/thumb.js:44:21)
at gm.emit (events.js:98:17)
at gm. (/usr/local/cozy/apps/photos/node_modules/gm/lib/getters.js:142:12)
at cb (/usr/local/cozy/apps/photos/node_modules/gm/lib/command.js:301:16)
at ChildProcess.spawn.proc.on.onExit (/usr/local/cozy/apps/photos/nodemodules/gm/lib/command.js:283:9)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess.handle.onexit (childprocess.js:822:5)

Our code allows two format of GPS data, but is wrong.

alexander-n8hgeg5e commented 8 years ago

I am the user. This is my photo app version: 1.0.19 I attached the file that failed, it has gps data in included:

img_20151011_173119

alexander-n8hgeg5e commented 8 years ago

This is the output of identify -verbose IMG_20151011_173119.jpg|grep -i gps

exif:GPSAltitude: 297299/1000
exif:GPSAltitudeRef: 0
exif:GPSDateStamp: 2015:10:11
exif:GPSImgDirection: 352/1
exif:GPSImgDirectionRef: M
exif:GPSInfo: 629
exif:GPSLatitude: 49/1, 16/1, 40907/1000
exif:GPSLatitudeRef: N
exif:GPSLongitude: 8/1, 5/1, 29506/1000
exif:GPSLongitudeRef: E
exif:GPSMapDatum: WGS-84
exif:GPSProcessingMethod: 65, 83, 67, 73, 73, 0, 0, 0, 71, 80, 83
exif:GPSStatus: A
exif:GPSTimeStamp: 15/1, 31/1, 20000/1000
exif:GPSVersionID: 2, 2, 0, 0
alexander-n8hgeg5e commented 8 years ago

Ok i found something out. I changed the code in thumb.js to: I added logging and commented the altitude part out: ... gpsDegToDec = function(pos, posRef) { var coord, ref, split, splitAlt; console.log(pos); split = pos.match(/(\d+)\/(\d+), (\d+)\/(\d+), (\d+)\/(\d+)/); ...

... orientation = data.Orientation; alt = 'exif:GPSAltitude'; lat = 'exif:GPSLatitude'; long = 'exif:GPSLongitude'; GPS = {}; console.log(data.Properties[alt]) //if (data.Properties[alt]) { // GPS.alt = gpsDegToDec(data.Properties[alt], data.Properties[alt + 'Ref']); //} console.log(data.Properties[lat]) if (data.Properties[lat]) { GPS.lat = gpsDegToDec(data.Properties[lat], data.Properties[lat + 'Ref']); } console.log(data.Properties[long]) if (data.Properties[long]) { GPS.long = gpsDegToDec(data.Properties[long], data.Properties[long + 'Ref']); }

And I got output: 297299/1000 49/1, 16/1, 40907/1000 49/1, 16/1, 40907/1000 8/1, 5/1, 29506/1000 8/1, 5/1, 29506/1000

The GPS data was imported then. Then I added console.log(posRef); to gpsDegToDec , enabled the altitude part and the output was: 297299/1000 297299/1000 0 "297299/1000" and "0" is what the altitude part transmits to gpsDegToDec as input. gpsDegToDec don't like "297299/1000" and "0". Unfortunately i do not know much about JavaScript and I know nothing about coffee script... I'm happy to have a picture on the map now :-) Nice.

clochix commented 8 years ago

Awesome! Thanks for your help, it will help us fix this quickly.

poupotte commented 8 years ago

This issue should be fixed in new version (1.0.21). @alexander-n8hgeg5e , is it ok for you ?

alexander-n8hgeg5e commented 8 years ago

Yes it works. :-) Only if I import from the files app, i think the gps data is not evaluated at all.

poupotte commented 8 years ago

Thanks @clochix and @alexander-n8hgeg5e :)