图片上传未检索 "Orientation" exif 数据
Image Upload Not Retrieving "Orientation" exif data
我正在尝试解决以下问题:当从手机上传肖像图像时,它在 desktop/browser 上打开时未保存为正确的方向。
我正在使用下面的代码获取 exif 数据以将其更改为正确的方向,但我遇到了问题:
$exif = exif_read_data($_FILES["file"]["tmp_name"], 0, true);
Error: Unexpected token a in JSON at position 0; array(4) {
["FILE"]=>
array(6) {
["FileName"]=>
string(11) "php18A7.tmp"
["FileDateTime"]=>
int(1490020599)
["FileSize"]=>
int(382988)
["FileType"]=>
int(2)
["MimeType"]=>
string(10) "image/jpeg"
["SectionsFound"]=>
string(19) "ANY_TAG, IFD0, EXIF"
}
["COMPUTED"]=>
array(5) {
["html"]=>
string(26) "width="2041" height="3628""
["Height"]=>
int(3628)
["Width"]=>
int(2041)
["IsColor"]=>
int(1)
["ByteOrderMotorola"]=>
int(1)
}
["IFD0"]=>
array(6) {
["ACDComment"]=>
string(37) "Windows Photo Editor 10.0.10011.16384"
["Orientation"]=>
int(8)
["Software"]=>
string(37) "Windows Photo Editor 10.0.10011.16384"
["DateTime"]=>
string(19) "2017:03:20 14:32:13"
["Exif_IFD_Pointer"]=>
int(2242)
["UndefinedTag:0xEA1C"]=>
string(2060) "�
}
}
上面显示的错误是 var_dump($exif)
在桌面浏览器上完成上传时的错误。如图所示,它检索 "Orientation" 数据,但是当我在移动设备上执行此操作时,它仅检索 "FILE" 数组和 "COMPUTED" 数组,并且都不包含 "ORIENTATION" 数据.
解决方案
我意识到每次它到达尝试使用 exif_read_data()
读取 exif 数据的地步时,数据都已经消失了。
我在 JavaScript 中检索了 exif 数据,而不是使用名为 exif.js. Further explanation found 的库。
我正在尝试解决以下问题:当从手机上传肖像图像时,它在 desktop/browser 上打开时未保存为正确的方向。
我正在使用下面的代码获取 exif 数据以将其更改为正确的方向,但我遇到了问题:
$exif = exif_read_data($_FILES["file"]["tmp_name"], 0, true);
Error: Unexpected token a in JSON at position 0; array(4) {
["FILE"]=>
array(6) {
["FileName"]=>
string(11) "php18A7.tmp"
["FileDateTime"]=>
int(1490020599)
["FileSize"]=>
int(382988)
["FileType"]=>
int(2)
["MimeType"]=>
string(10) "image/jpeg"
["SectionsFound"]=>
string(19) "ANY_TAG, IFD0, EXIF"
}
["COMPUTED"]=>
array(5) {
["html"]=>
string(26) "width="2041" height="3628""
["Height"]=>
int(3628)
["Width"]=>
int(2041)
["IsColor"]=>
int(1)
["ByteOrderMotorola"]=>
int(1)
}
["IFD0"]=>
array(6) {
["ACDComment"]=>
string(37) "Windows Photo Editor 10.0.10011.16384"
["Orientation"]=>
int(8)
["Software"]=>
string(37) "Windows Photo Editor 10.0.10011.16384"
["DateTime"]=>
string(19) "2017:03:20 14:32:13"
["Exif_IFD_Pointer"]=>
int(2242)
["UndefinedTag:0xEA1C"]=>
string(2060) "�
}
}
上面显示的错误是 var_dump($exif)
在桌面浏览器上完成上传时的错误。如图所示,它检索 "Orientation" 数据,但是当我在移动设备上执行此操作时,它仅检索 "FILE" 数组和 "COMPUTED" 数组,并且都不包含 "ORIENTATION" 数据.
解决方案
我意识到每次它到达尝试使用 exif_read_data()
读取 exif 数据的地步时,数据都已经消失了。
我在 JavaScript 中检索了 exif 数据,而不是使用名为 exif.js. Further explanation found