我有一个脚本可以将照片上传到用 PHP 编写的网站。当我在我的 iPhone 上使用 Safari 上传图片时,当我检查 exif 数据时,某些标题似乎被剥离。当我从我的 iPhone 拍摄完全相同的照片并将其通过电子邮件发送给自己并从计算机上传时,所有的 exif 数据都在那里。
我想知道 iPhone 上是否有一个设置或我缺少的 PHP 脚本,当我尝试从我的 iPhone 上传时,它可以让我抓住 exif 的 GPS 部分。当我通过我的 iPhone 将图片上传到我的网站时,我想要的只是从 exif_read_data 中获取 GPS 阵列。
我在 Iphone 上的 Safari 中的 Exif 示例:
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
用同一部手机拍摄的从我的 PC 上传的同一张图片的 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("[...]");?>