我有一個腳本來上傳照片到用PHP編寫的網站。當我在iPhone上使用Safari上傳圖片時,當檢查exif數據時,某些標題似乎被剝離。當我從我的iPhone上拍攝完全相同的照片並通過電子郵件發送給我自己並從計算機上傳時,所有exif數據都在那裏。exif上傳圖片與移動設備上的PHP剝離GPS頭?
我想知道是否有一個iPhone或PHP腳本的設置,我錯過了,當我嘗試從我的iPhone上傳時,會讓我抓住exif的GPS部分。我想要的是當我通過iPhone上傳圖片到我的網站時,從exif_read_data獲取GPS數組。
一個的Exif例如從我的iPhone上的Safari:
Image type is: JPEG
FILE.FileName: 20130417141031image.jpg
FILE.FileDateTime: 1366225831
FILE.FileSize: 1692449
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG, IFD0, EXIF
COMPUTED.html: width="3264" height="2448"
COMPUTED.Height: 2448
COMPUTED.Width: 3264
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
IFD0.Orientation: 6
IFD0.Exif_IFD_Pointer: 38
EXIF.ColorSpace: 1
EXIF.ExifImageWidth: 3264
EXIF.ExifImageLength: 2448
由同一手機拍攝的我的電腦上傳同一圖像的
一個的Exif例如:
Image type is: JPEG
FILE.FileName: 20130417142504image.jpeg
FILE.FileDateTime: 1366226835
FILE.FileSize: 1744896
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS
COMPUTED.html: width="3264" height="2448"
COMPUTED.Height: 2448
COMPUTED.Width: 3264
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 1
COMPUTED.ApertureFNumber: f/2.4
COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
IFD0.Make: Apple
IFD0.Model: iPhone 4S
IFD0.Orientation: 6
IFD0.XResolution: 72/1
IFD0.YResolution: 72/1
IFD0.ResolutionUnit: 2
IFD0.Software: 6.1.3
IFD0.DateTime: 2013:04:17 15:13:39
IFD0.YCbCrPositioning: 1
IFD0.Exif_IFD_Pointer: 204
IFD0.GPS_IFD_Pointer: 594
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 72/1
THUMBNAIL.YResolution: 72/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 890
THUMBNAIL.JPEGInterchangeFormatLength: 7684
EXIF.ExposureTime: 1/20
EXIF.FNumber: 12/5
EXIF.ExposureProgram: 2
EXIF.ISOSpeedRatings: 50
EXIF.ExifVersion: 0221
EXIF.DateTimeOriginal: 2013:04:17 15:13:39
EXIF.DateTimeDigitized: 2013:04:17 15:13:39
EXIF.ComponentsConfiguration:
EXIF.ShutterSpeedValue: 2779/643
EXIF.ApertureValue: 4845/1918
EXIF.BrightnessValue: 13523/4727
EXIF.MeteringMode: 3
EXIF.Flash: 16
EXIF.FocalLength: 107/25
EXIF.SubjectLocation: Array
EXIF.FlashPixVersion: 0100
EXIF.ColorSpace: 1
EXIF.ExifImageWidth: 3264
EXIF.ExifImageLength: 2448
EXIF.SensingMethod: 2
EXIF.ExposureMode: 0
EXIF.WhiteBalance: 0
EXIF.FocalLengthIn35mmFilm: 35
EXIF.SceneCaptureType: 0
GPS.GPSLatitudeRef: N
GPS.GPSLatitude: Array
GPS.GPSLongitudeRef: W
GPS.GPSLongitude: Array
GPS.GPSAltitudeRef:
GPS.GPSAltitude: 55556/297
GPS.GPSTimeStamp: Array
GPS.GPSImgDirectionRef: T
GPS.GPSImgDirection: 19688/145
下面是代碼,我使用我的PHP腳本的照片,我刪除了標題,並要求:
<?php
require('[...]');
mysql_select_db($db_name, $oConn);
$JobNum = $_POST['JobNum'];
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 10000000))
{
if ($_FILES["file"]["error"] > 0)
{
ps_log("Bad Photo Upload - Return Code: " . $_FILES["file"]["error"]);
}
else
{
ps_log("Upload: " . $_FILES["file"]["name"]);
ps_log("Type: " . $_FILES["file"]["type"]);
ps_log("Size: " . ($_FILES["file"]["size"]/1024) . " Kb");
ps_log("Temp file: " . $_FILES["file"]["tmp_name"] . "<br />");
$photoname = $_FILES['file']['tmp_name'];
$root = "[...]";
$location = $_SERVER['DOCUMENT_ROOT'].$root.$photoname;
$exif = exif_read_data($photoname, 0, true);
$filename = $exif["FILE"]["FileName"];
$model = $exif["IFD0"]["Model"];
$date = $exif["IFD0"]["DateTime"];
$lon = $exif["GPS"]["GPSLongitude"];
$lonref = $exif["GPS"]['GPSLongitudeRef'];
$lat = $exif["GPS"]["GPSLatitude"];
$latref = $exif["GPS"]['GPSLatitudeRef'];
$lon = Photos::getGps($lon, $lonref);
$lat = Photos::getGps($lat, $latref);
$photo = new UploadedPhoto();
$photo->JobNum = $JobNum;
$photo->TempFile = $_FILES["file"]["tmp_name"];
$photo->FileName = $_FILES["file"]["name"];
$photo->Comments = $_POST['Comment'];
$photo->Model = $model ;
$photo->DateStamp = $date ;
$photo->Lat = $lat ;
$photo->Lng = $lon ;
$photo->SaveGeo();
}
}
else
{
echo "Invalid file";
}
header("[...]");?>
將文件上傳到網站一向怪異iOS中。剝離個人數據是iOS的「特徵」,而不是bug。 https://www.google.com/search?btnG=1&pws=0&q=image+upload+iphone+exif – user1666456
我爲我的網站使用rails和jquery-file-upload,而且我遇到同樣的問題。從PC上載相同的圖像文件有完整的EXIF信息,而從iPhone只有基本信息(沒有GPS信息)。這是可悲的。 – Alston
我相信這樣做的原因是人們將圖片上傳到社交網絡等方面的隱私問題 - 以防止將孩子的位置送給陌生人等等。服務器端沒有任何東西可以做。 – Jason