从iphone上传图片上传exif数据 [英] Image upload from iphone strips exif data

查看:861
本文介绍了从iphone上传图片上传exif数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个允许上传图片的网站,一旦图片上传,就会显示一些关于图片的特定信息。
从电脑上传图片效果很好,当我试图从智能手机上传图片时,问题就出现了。上传成功,但它似乎是从电脑上传时显示的数据的重要组成部分,现在缺少。

这个代码段是实际检索和显示数据:

  $ location = $ _FILES [pic] [tmp_name]; 
$ data = exif_read_data($ location);
var_dump($ data);

var_dump($ data)实际转储不同的数据在计算机和智能手机。

编辑:显然它工作得很好Andoroid智能手机,只有当我尝试从iPhone上传图像



例如,计算机中的 var_dump 上传:

  array(49){
[FileName] =>字符串(10)php2D4.tmp
[FileDateTime] => int(1367318152)
[FileSize] => int(30357)
[FileType] => int(2)
[MimeType] =>字符串(10)image / jpeg
[SectionsFound] =>字符串(24)ANY_TAG,IFD0,EXIF,GPS
[COMPUTED] => array(6){
[html] => string(24)width =320height =240
[Height] => int(240)
[Width] => int(320)
[IsColor] => int(1)
[ByteOrderMotorola] => int(1)
[ApertureFNumber] =>字符串(5)f / 2.8
}
[Make] =>字符串(5)Apple
[Model] =>字符串(8)iPhone 4
[Orientation] => int(3)
[XResolution] =>字符串(4)72/1
[YResolution] =>字符串(4)72/1
[ResolutionUnit] => int(2)
[Software] =>字符串(5)6.1.3
[DateTime] => (19)2013:04:26 23:57:43
[YCbCrPositioning] => int(1)
[Exif_IFD_Pointer] => int(204)
[GPS_IFD_Pointer] => int(594)
[ExposureTime] =>字符串(4)1/15
[FNumber] =>字符串(4)14/5
[ExposureProgram] => int(2)
[ISOSpeedRatings] => int(1000)
[ExifVersion] =>字符串(4)0221
[DateTimeOriginal] =>字符串(19)2013:04:26 23:57:43
[DateTimeDigitized] =>字符串(19)2013:04:26 23:57:43
[ComponentsConfiguration] =>字符串(4)
[ShutterSpeedValue] =>字符串(9)4889/1250
[ApertureValue] =>字符串(9)4281/1441
[BrightnessValue] =>字符串(10)-3581/1451
[MeteringMode] => int(5)
[Flash] => int(24)
[FocalLength] =>字符串(5)77/20
[SubjectLocation] =>数组(4){
[0] => int(1295)
[1] => int(967)
[2] => int(699)
[3] => int(696)
}
[FlashPixVersion] =>字符串(4)0100
[ColorSpace] => int(1)
[ExifImageWidth] => int(2592)
[ExifImageLength] => int(1936)
[SensingMethod] => int(2)
[ExposureMode] => int(0)
[WhiteBalance] => int(0)
[FocalLengthIn35mmFilm] => int(35)
[SceneCaptureType] => int(0)
[GPSLatitudeRef] =>字符串(1)N
[GPSLatitude] =>数组(3){
[0] =>字符串(4)31/1
[1] =>字符串(8)5854/100
[2] =>字符串(3)0/1
}
[GPSLongitudeRef] =>字符串(1)E
[GPSLongitude] =>数组(3){
[0] =>字符串(4)34/1
[1] =>字符串(8)4684/100
[2] =>字符串(3)0/1
}
[GPSTimeStamp] =>数组(3){
[0] =>字符串(4)20/1
[1] =>字符串(4)57/1
[2] =>字符串(8)4272/100
}
[GPSImgDirectionRef] =>字符串(1)T
[GPSImgDirection] => string(9)48089/465
}

var_dump 智能手机上传:

  array(12){
[FileName] =>字符串(9)phpSzwfPw
[FileDateTime] => int(1367318054)
[FileSize] => int(1778041)
[FileType] => int(2)
[MimeType] =>字符串(10)image / jpeg
[SectionsFound] =>字符串(19)ANY_TAG,IFD0,EXIF
[COMPUTED] =>数组(5){
[html] => (26)width =2592height =1936
[Height] => int(1936)
[Width] => int(2592)
[IsColor] => int(1)
[ByteOrderMotorola] => int(1)
}
[Orientation] => int(3)
[Exif_IFD_Pointer] => int(38)
[ColorSpace] => int(1)
[ExifImageWidth] => int(2592)
[ExifImageLength] => int(1936)
}

这是计算机 {[name] =>串(18)leaf2.JPG
[ 型] =>串(10) 图像/ JPEG
[ tmp_name的值] =>串(14)/ TMP / phpzeDUs9
[error] => int(0)
[size] => int(46439)}}
$ b

以下是 iPhone 结果 var_dump($ _ FILES)



$ $ $ $ $ $ $ $ $ $ {$ $ $ $ $ $ $ $'$'$'$'$' 9)image.jpg
[type] => string(10)image / jpeg
[tmp_name] => string(14)/ tmp / phplPUZky
[error] => int(0)[size] => int(1455577)}}

编辑:这里是上传表单的HTML代码:

  < form action =results.phpid =upload-imagemethod =postenctype =multipart / form-data> 
< div class =fileupload fileupload- provides =fileupload>
< div class =fileupload-preview thumbnailstyle =width:200px;高度:150像素; >< / DIV>
将DIV>
将跨度类= BTN BTN-文件 ><跨度类= 文件上传新>选择图片< / span>< span class =fileupload-exists>更改< / span>< input type =filename =picid =picaccept =image / */> < /跨度>
将A HREF = # 类= BTN文件上传-存在 数据解雇= 文件上传 >删除< / A>
将按钮型=提交类= BTN >上传< /按钮>
将/ BR>
将跨度类= 上传错误>< /跨度>
将/ div>
< / form>

什么可能导致它? b $ b

解决方案

问题

(ipad等,我从现在开始称它为iphone)剥离exif数据。这也不是iPhone上的错误,但实际上是一个功能。



一个android u的主要原因sers不喜欢iphone和iphone用户不喜欢androids,是因为iphone是非常有限的(在自由方面改变,改变等)。你不能只运行下载的应用程序,限制访问设置等。

这是因为苹果的战略是创建一个安全的产品。 如果你做不到奇怪的事情,就不会有奇怪的事情发生。它试图以各种可以想象的方式来保护用户。上传图片时也保护用户。在exif可能有数据可能会伤害用户的隐私。像GPS坐标这样的东西,但即使是一个时间戳,也可能会伤害到用户(想象一下,从你报告老板生病的那一刻起,你就可以上传一张带有时间戳的海滩图片)。

所以基本上这是一个安全的措施来剥离所有exif数据。我自己和很多其他人不同意这个策略,但是不幸的是,我们无能为力。

/ p>

更新:这不起作用。 (感谢likeitlikeit这个信息)



幸运的是,你可以解决这个问题。 JavaScript来救援。使用JavaScript,您可以读取exif数据并通过添加一些额外的POST数据将其发送给您。



请注意:此解决方案已呈现由另一个开发者给我,还没有测试。

消息来源

您要求可信的来源。不幸的是,他们很难找到,因为苹果是不是一直在说话,因此,我所有的信息是传闻。

也许我可以提供的一个更可靠的来源是谁确认的根本原因是flickr的工作人员是移动的safari剥离exif。
http://www.flickr.com/help/ forum / en-us / 72157632100391901 /#reply72157632135956813


I've built a website which allows image uploading and once an image is uploaded , some specific information about the photo is displayed. Uploading pictures from computers works just fine , the problem comes up when I'm trying to upload an image from a smartphone. The upload success but it seems like a major part of the data that is displayed when uploading from computer is now missing.

This code section is the one that actually retrieves and display the data :

$location = $_FILES["pic"]["tmp_name"];
$data = exif_read_data($location);
var_dump($data);

the var_dump($data) actually dumps different data in computers and smartphones.

EDIT : Apparently it works just fine with Andoroid smartphones, the problem only comes up when I try to upload images from iPhone

For example, var_dump from computer upload :

array(49) { 
    ["FileName"]=> string(10) "php2D4.tmp" 
    ["FileDateTime"]=> int(1367318152) 
    ["FileSize"]=> int(30357) 
    ["FileType"]=> int(2) 
    ["MimeType"]=> string(10) "image/jpeg" 
    ["SectionsFound"]=> string(24) "ANY_TAG, IFD0, EXIF, GPS" 
    ["COMPUTED"]=> array(6) { 
        ["html"]=> string(24) "width="320" height="240""  
        ["Height"]=> int(240)  
        ["Width"]=> int(320)  
        ["IsColor"]=> int(1)  
        ["ByteOrderMotorola"]=> int(1)  
        ["ApertureFNumber"]=> string(5) "f/2.8"  
    }  
    ["Make"]=> string(5) "Apple"  
    ["Model"]=> string(8) "iPhone 4"  
    ["Orientation"]=> int(3)  
    ["XResolution"]=> string(4) "72/1"  
    ["YResolution"]=> string(4) "72/1"  
    ["ResolutionUnit"]=> int(2)  
    ["Software"]=> string(5) "6.1.3"  
    ["DateTime"]=> string(19) "2013:04:26 23:57:43"  
    ["YCbCrPositioning"]=> int(1)  
    ["Exif_IFD_Pointer"]=> int(204)  
    ["GPS_IFD_Pointer"]=> int(594)  
    ["ExposureTime"]=> string(4) "1/15"  
    ["FNumber"]=> string(4) "14/5"  
    ["ExposureProgram"]=> int(2)  
    ["ISOSpeedRatings"]=> int(1000)  
    ["ExifVersion"]=> string(4) "0221"  
    ["DateTimeOriginal"]=> string(19) "2013:04:26 23:57:43"  
    ["DateTimeDigitized"]=> string(19) "2013:04:26 23:57:43"  
    ["ComponentsConfiguration"]=> string(4) ""  
    ["ShutterSpeedValue"]=> string(9) "4889/1250"  
    ["ApertureValue"]=> string(9) "4281/1441"  
    ["BrightnessValue"]=> string(10) "-3581/1451"  
    ["MeteringMode"]=> int(5)  
    ["Flash"]=> int(24)  
    ["FocalLength"]=> string(5) "77/20"  
    ["SubjectLocation"]=> array(4) {  
        [0]=> int(1295) 
        [1]=> int(967) 
        [2]=> int(699) 
        [3]=> int(696) 
    } 
    ["FlashPixVersion"]=> string(4) "0100" 
    ["ColorSpace"]=> int(1) 
    ["ExifImageWidth"]=> int(2592) 
    ["ExifImageLength"]=> int(1936) 
    ["SensingMethod"]=> int(2) 
    ["ExposureMode"]=> int(0) 
    ["WhiteBalance"]=> int(0) 
    ["FocalLengthIn35mmFilm"]=> int(35) 
    ["SceneCaptureType"]=> int(0) 
    ["GPSLatitudeRef"]=> string(1) "N" 
    ["GPSLatitude"]=> array(3) { 
        [0]=> string(4) "31/1" 
        [1]=> string(8) "5854/100" 
        [2]=> string(3) "0/1" 
    } 
    ["GPSLongitudeRef"]=> string(1) "E" 
    ["GPSLongitude"]=> array(3) { 
        [0]=> string(4) "34/1" 
        [1]=> string(8) "4684/100" 
        [2]=> string(3) "0/1" 
    } 
    ["GPSTimeStamp"]=> array(3) { 
        [0]=> string(4) "20/1" 
        [1]=> string(4) "57/1" 
        [2]=> string(8) "4272/100" 
    } 
    ["GPSImgDirectionRef"]=> string(1) "T" 
    ["GPSImgDirection"]=> string(9) "48089/465" 
}

var_dump from smartphone upload:

array(12) { 
    ["FileName"]=> string(9) "phpSzwfPw" 
    ["FileDateTime"]=> int(1367318054) 
    ["FileSize"]=> int(1778041) 
    ["FileType"]=> int(2) 
    ["MimeType"]=> string(10) "image/jpeg" 
    ["SectionsFound"]=> string(19) "ANY_TAG, IFD0, EXIF" 
    ["COMPUTED"]=> array(5) { 
        ["html"]=> string(26) "width="2592" height="1936"" 
        ["Height"]=> int(1936) 
        ["Width"]=> int(2592) 
        ["IsColor"]=> int(1) 
        ["ByteOrderMotorola"]=> int(1) 
    } 
    ["Orientation"]=> int(3) 
    ["Exif_IFD_Pointer"]=> int(38) 
    ["ColorSpace"]=> int(1) 
    ["ExifImageWidth"]=> int(2592) 
    ["ExifImageLength"]=> int(1936) 
}

Here's the computer var_dump($_FILES) :

    array(1) 
{ ["pic"]=> array(5) 
{ ["name"]=> string(18) leaf2.JPG" 
["type"]=> string(10) "image/jpeg" 
["tmp_name"]=> string(14) "/tmp/phpzeDUs9"
 ["error"]=> int(0)
 ["size"]=> int(46439) } }

Here's the iPhone results var_dump($_FILES) :

    array(1) { ["pic"]=> array(5) 
{ ["name"]=> string(9) "image.jpg" 
["type"]=> string(10) "image/jpeg" 
["tmp_name"]=> string(14) "/tmp/phplPUZky" 
["error"]=> int(0) ["size"]=> int(1455577) } } 

EDIT : Here is the uploading form HTML code:

     <form action="results.php" id="upload-image" method="post" enctype="multipart/form-data">
         <div class="fileupload fileupload-new" data-provides="fileupload">
          <div class="fileupload-preview thumbnail" style="width: 200px; height: 150px;"></div>
          <div>
            <span class="btn btn-file"><span class="fileupload-new">Select image</span><span class="fileupload-exists">Change</span><input type="file" name="pic" id="pic" accept="image/*"/></span>
            <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
            <button type="submit" class="btn">Upload</button>
            </br>
            <span class="upload-error"></span>
          </div>
     </form>

What might cause it?

解决方案

The problem

It is correct that the iphone(ipad, etc, i'll just call it iphone from now on) strips exif data. This is also not a bug on the iphone but actually a feature.

One of the main reasons android users don't like the iphone and iphone users don't like the androids, is because the iphone is very limited (in terms of freedom to change, alter, etc). You can not just run downloaded apps, have limited access to settings, etc.

This is because the apple strategy is to create a fail-safe product. "If you can not do strange things, strange things will not happen".It tries to protect the user in every way imaginable. It also protects the user when uploading images. In the exif there may be data that can hurt the users privacy. Things like GPS coordinates, but even a timestamp can hurt a user (imagine you uploading a beach picture with a timestamp from a moment you reported in sick with the boss).

So basically it is a safety meassure to strip all exif data. Myself and a lot of other people do not agree with this strategy, but there is nothing we can do about it unfortunately.

The solution

Update: This does not work. (thanks likeitlikeit for this info)

Luckily you can get around this problem. Javascript comes to the rescue. With javascript you can read the exif data and send it with you photo by adding some extra POST data.

please note: this solution was presented to me by another developer and is not yet tested.

Sources

You are asking for credible sources. Unfortunately they are hard to find as apple is not talking as always and therefore all information i have is hearsay.

perhaps one of the more reliable sources i can present is one of the flickr staffmembers who confirms that the root cause is mobile safari stripping the exif. http://www.flickr.com/help/forum/en-us/72157632100391901/#reply72157632135956813

这篇关于从iphone上传图片上传exif数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆