lnmp安装exif扩展
lnmp安装exif扩展
1.找到位置
cd /usr/local/lnmp1.4-full/src
2.解压php
sudo bzip2 -d php-5.6.31.tar.bz2
sudo tar -xvf php-5.6.31.tar
3.进入php
cd /usr/local/lnmp1.4-full/src/php-5.6.31/ext
4.进入exif
cd exif && /usr/local/php/bin/phpize
5.配置
./configure --with-php-config=/usr/local/php/bin/php-config
6.安装
sudo make && sudo make install
7.增加配置
cd /usr/local/php/conf.d
sudo vim 008-exif.ini
extension = "exif.so"
8.重启php
service php-fpm restart
9.查看
php -m
$ php -m |grep exif
exif
<?php
$file_arr = read_exif_data('./photo.jpg');
var_dump($file_arr);
array(45) {
["FileName"]=>
string(9) "photo.jpg"
["FileDateTime"]=>
int(1533333328)
["FileSize"]=>
int(7941835)
["FileType"]=>
int(2)
["MimeType"]=>
string(10) "image/jpeg"
["SectionsFound"]=>
string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF"
["COMPUTED"]=>
array(8) {
["html"]=>
string(26) "width="3479" height="4567""
["Height"]=>
int(4567)
["Width"]=>
int(3479)
["IsColor"]=>
int(1)
["ByteOrderMotorola"]=>
int(0)
["ApertureFNumber"]=>
string(5) "f/2.8"
["Thumbnail.FileType"]=>
int(2)
["Thumbnail.MimeType"]=>
string(10) "image/jpeg"
}
["Make"]=>
string(5) "Canon"
["Model"]=>
string(12) "Canon EOS 6D"
["XResolution"]=>
string(5) "300/1"
["YResolution"]=>
string(5) "300/1"
["ResolutionUnit"]=>
int(2)
["Software"]=>
string(40) "Adobe Photoshop Camera Raw 8.5 (Windows)"
["DateTime"]=>
string(19) "2018:08:04 11:18:27"
["Exif_IFD_Pointer"]=>
int(208)
["THUMBNAIL"]=>
array(6) {
["Compression"]=>
int(6)
["XResolution"]=>
string(4) "72/1"
["YResolution"]=>
string(4) "72/1"
["ResolutionUnit"]=>
int(2)
["JPEGInterchangeFormat"]=>
int(844)
["JPEGInterchangeFormatLength"]=>
int(13311)
}
["ExposureTime"]=>
string(5) "1/125"
["FNumber"]=>
string(5) "28/10"
["ExposureProgram"]=>
int(1)
["ISOSpeedRatings"]=>
int(160)
["UndefinedTag:0x8830"]=>
int(2)
["UndefinedTag:0x8832"]=>
int(160)
["ExifVersion"]=>
string(4) "0230"
["DateTimeOriginal"]=>
string(19) "2018:07:15 15:36:12"
["DateTimeDigitized"]=>
string(19) "2018:07:15 15:36:12"
["ShutterSpeedValue"]=>
string(15) "6965784/1000000"
["ApertureValue"]=>
string(15) "2970854/1000000"
["ExposureBiasValue"]=>
string(3) "0/1"
["MaxApertureValue"]=>
string(3) "1/1"
["MeteringMode"]=>
int(2)
["Flash"]=>
int(16)
["FocalLength"]=>
string(4) "50/1"
["SubSecTimeOriginal"]=>
string(2) "11"
["SubSecTimeDigitized"]=>
string(2) "11"
["FocalPlaneXResolution"]=>
string(12) "5472000/1436"
["FocalPlaneYResolution"]=>
string(11) "3648000/956"
["FocalPlaneResolutionUnit"]=>
int(2)
["CustomRendered"]=>
int(0)
["ExposureMode"]=>
int(1)
["WhiteBalance"]=>
int(1)
["SceneCaptureType"]=>
int(0)
["UndefinedTag:0xA431"]=>
string(12) "334021005410"
["UndefinedTag:0xA432"]=>
array(4) {
[0]=>
string(4) "50/1"
[1]=>
string(4) "50/1"
[2]=>
string(3) "0/0"
[3]=>
string(3) "0/0"
}
["UndefinedTag:0xA434"]=>
string(16) "EF50mm f/1.4 USM"
["UndefinedTag:0xA435"]=>
string(10) "0000000000"
}
以下几种方式都可以
$file_arr = read_exif_data('./photo.jpg');
$file_arr = read_exif_data('https://cdn.caomall.net/15344950781428748118.jpg');
$file_arr = read_exif_data($_FILES[$file_name]['tmp_name']);