Cannot read GPS Coordinates after "Take Photo" option

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
alexdorfman
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jan 23, 2017 6:53 pm

Mon Jan 23, 2017 7:09 pm

Hi!
I created app to read Geo Location using exif_read_data function.

$info = exif_read_data($file);
if (isset($info['GPSLatitude']) && isset($info['GPSLongitude']) &&
isset($info['GPSLatitudeRef']) && isset($info['GPSLongitudeRef']) &&
in_array($info['GPSLatitudeRef'], array('E','W','N','S')) && in_array($info['GPSLongitudeRef'], array('E','W','N','S'))) {

$GPSLatitudeRef = strtolower(trim($info['GPSLatitudeRef']));
...................................... and so on
}

It works for all pictures ALREADY TAKEN (from "Photo Library"). If I want to use an option "Take Photo",
isset($info['GPSLatitude']) IS FALSE.

Is it something about security?

Thanks,
Alex

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 526
Joined: Mon Feb 22, 2016 5:52 pm

Tue Jan 24, 2017 11:01 am

I'm assuming that your "Take Photo" option is using an inbuilt camera in the device you are running the script from, if this is the case then:

The camera software may not provide a gps location
The camera software may not provide exif data
The camera software may not provide exif data that exif_read_data can read
When loading the photo onto your computer, it may wipe away the exif data, especially if processing the image through PHP first.

Exif data is an optional thing and not all cameras provide the information or may have their own way of providing it, so exif_read_data can have serious limitations.

alexdorfman
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jan 23, 2017 6:53 pm

Tue Jan 24, 2017 12:39 pm

Thank you hyper!
If the camera software is not providing a gps location, why I was able to get coordinates after:

I saved the image on the camera;
I uploaded this image to my program?

I'm using iPhone 6.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 526
Joined: Mon Feb 22, 2016 5:52 pm

Tue Jan 24, 2017 5:24 pm

Was your "ALREADY TAKEN (from "Photo Library")." taken using the same phone?

alexdorfman
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jan 23, 2017 6:53 pm

Wed Jan 25, 2017 7:01 am

Yes! Same iPhone.
And I used the same iPhone to upload the pic.

Scenario 1:
I took a pic
Opened app to upload a file
Selected (from "Photo Library") - got coordinates!

Scenario 2:
Opened app to upload a file
Selected "Take Photo" - no coordinates! :-(

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 526
Joined: Mon Feb 22, 2016 5:52 pm

Fri Jan 27, 2017 1:09 pm

So the same script (shown in first post) is used for both options, using the same phone? it is just the location from where the photo is uploaded from ("Photo Library", "Take Photo") that is different?

Does the "Take Photo" option literally take the photo then upload it?

Where is the script executed?

alexdorfman
New php-forum User
New php-forum User
Posts: 4
Joined: Mon Jan 23, 2017 6:53 pm

Sat Jan 28, 2017 8:35 am

1. Yes, the same script, and only the uploaded option is different.
2. Yes. I noticed after "Take Photo" option iPhone didn't save the picture in the library. Uploading happened, but no coordinates info in the header.
My only guess is the system adds Geolocation information into the header during saving to the "Photo Library".
3. On the server: LINUX, PHP 5

Thank you Hyper!

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 526
Joined: Mon Feb 22, 2016 5:52 pm

Sun Jan 29, 2017 12:31 pm

My only guess is the system adds Geolocation information into the header during saving to the "Photo Library".
I agree, it's a reminder when writing your own scripts to keep an open mind as to how people will actually use it :?

Post Reply