1

I cannot figure out why using Exif within php, when an image is uploaded via choosing an "existing photo" on, in this case, an iPhone 6plus and Samsung Android, that I get full exif data which includes all of it including GPS data; but when I choose to "take a photo" and then upload it via same process, the Exif data is truncated and I no longer get to the GPS data which is toward the end. It stops at end of " ... ExifImageLength"]=>int(2448)".

Here is the script I am using (which is a part of a greater script to resize an uploaded image and store data from a form and Exif data of uploaded image. But I am only using the below code as a test and it still does it.

if (empty($_FILES['image']['name'])) {
        echo 'Please choose an image!';
}   else {
     $temp = $_FILES['image']['tmp_name'];
     $info = @exif_read_data($temp);
     var_dump($info);
 }

I have a local development server using XAMPP where everything is just fine with both "taken" or "chosen" images. But I am having this truncated issue on a GoDaddy Virtual Server Linux.

James
  • 561
  • 2
  • 7
  • 19
  • If you take off that `@` does it give you an error? – chris85 Mar 25 '16 at 14:11
  • ...using => http://php.net/manual/en/function.error-reporting.php – Funk Forty Niner Mar 25 '16 at 14:11
  • I turn on Error reporting and remove "@" and It still does it and gives no error. I use ... ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL | E_STRICT); – James Mar 25 '16 at 14:16
  • what is the php version on the vps ? could you give exact version which I mean with minor version included. – FZE Mar 25 '16 at 14:17
  • on the XAMPP server it was PHP 5.6.15 and I upgraded the version on the GoDaddy from 5.5.31 to 5.6.19. So currently it is 5.6.19. – James Mar 25 '16 at 14:18
  • Btw, Could you please check http://php.net/manual/tr/function.exif-read-data.php#110894 following comment it may be the same problem you are encountering. – FZE Mar 25 '16 at 14:19
  • @FZE Good suggestion but you should use an English version when referencing PHP.net rather than Turkish, should they want to read the rest of that page http://php.net/manual/en/function.exif-read-data.php#110894 *just saying* ;) – Funk Forty Niner Mar 25 '16 at 14:25
  • Orientation is not the issue. We have that working. For some unknown reason on this server I am having a truncated issue with the Exif data when a photo is taken vs. when photo is uploaded from choosing an existing one. – James Mar 25 '16 at 14:25
  • @Fred-ii- oops I just missed that thanks for it, I will fix the link :) – FZE Mar 25 '16 at 14:26
  • @James I did check all the change logs between 5.6.15 5.6.19 there is no sign about exif. I'm not sure but there may be a trick about the GD version on the server etc. just an idea have you checked them ? – FZE Mar 25 '16 at 14:32
  • Can you take a look at this Q&A http://stackoverflow.com/q/30177313/ see if that helps any, as well as comments in there. Could also be UTF-8 related. Hard to say. – Funk Forty Niner Mar 25 '16 at 14:35
  • @FZE - Both XAMPP and GoDaddy VPS has GD Version "bundle (2.1.0 compatible) but XAMPP shows that it has a FreeType Version "2.5.5" and VPS has Version "2.3.11"; and XAMPP has libPNG Version as "1.5.18" and VPS has "1.2.49"; and XAMPP has WebP Support enable and VPS does not even show that listed. Also, XAMPP shows libJPEG Version as "6b" and VPS has "9 compatible". – James Mar 25 '16 at 14:46

1 Answers1

0

After a long research into this, I have discovered that when someone chooses to "take photo" at the moment when uploading a photo to a website, only the basic EXIF data is stored and not the extras such as GPS data, etc. When they "Choose from Library" the data is stored with the photo because it was already taken and stored on the mobile device. I have noticed that when they take a photo after clicking a website's "choose image" form input, that it does not save to the mobile device and apparently that is why the extra data does not get recorded. Only when they take a photo to be stored on the mobile device is the extra EXIF data stored, not when they bypass that and it goes straight to website for uploading. I even had the photo stored untouched to the server and then run my scripts for the extra EXIF and no such info got recorded. I have tested this on a lot of other websites that will allow you to upload to get map coordinates of the photo and the truncated results are consistent with them as well as with my scripts that I have created. I stand to be corrected, but after much research this is the only conclusion I can come up with using my experimentation. So far, nowhere can I find an explanation other than what I have suggested. I will put this as an answer to my own question and welcome anyone who is more of an expert than I am to rebuttal or affirm.

James
  • 561
  • 2
  • 7
  • 19