PHPIN.NET

 找回密码
 立即注册
查看: 6334|回复: 0

[高级进阶] PHP 获取图片信息exif

[复制链接]

469

主题

31

回帖

5509

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
5509
发表于 2017-8-16 20:17:23 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
PHP 获取图片信息exif

代码:
  1. $file_arr = read_exif_data('./1.png');  
  2. var_dump($file_arr);  
复制代码
结果:
  1. array (size=49)
  2.   'FileName' => string '2.png' (length=5)
  3.   'FileDateTime' => int 1446107171
  4.   'FileSize' => int 2640955
  5.   'FileType' => int 2
  6.   'MimeType' => string 'image/jpeg' (length=10)
  7.   'SectionsFound' => string 'ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP' (length=39)
  8.   'COMPUTED' =>
  9.     array (size=12)
  10.       'html' => string 'width="4128" height="2322"' (length=26)
  11.       'Height' => int 2322
  12.       'Width' => int 4128
  13.       'IsColor' => int 1
  14.       'ByteOrderMotorola' => int 0
  15.       'ApertureFNumber' => string 'f/2.2' (length=5)
  16.       'UserComment' => null
  17.       'UserCommentEncoding' => string 'ASCII' (length=5)
  18.       'Thumbnail.FileType' => int 2
  19.       'Thumbnail.MimeType' => string 'image/jpeg' (length=10)
  20.       'Thumbnail.Height' => int 288
  21.       'Thumbnail.Width' => int 512
  22.   'ImageWidth' => int 4128
  23.   'ImageLength' => int 2322
  24.   'Make' => string 'SAMSUNG' (length=7)
  25.   'Model' => string 'GT-I9500' (length=8)
  26.   'Orientation' => int 3
  27.   'XResolution' => string '72/1' (length=4)
  28.   'YResolution' => string '72/1' (length=4)
  29.   'ResolutionUnit' => int 2
  30.   'Software' => string 'I9500ZCUHND1' (length=12)
  31.   'DateTime' => string '2015:10:29 16:05:28' (length=19)
  32.   'YCbCrPositioning' => int 1
  33.   'Exif_IFD_Pointer' => int 226
  34.   'THUMBNAIL' =>
  35.     array (size=9)
  36.       'ImageWidth' => int 512
  37.       'ImageLength' => int 288
  38.       'Compression' => int 6
  39.       'Orientation' => int 3
  40.       'XResolution' => string '72/1' (length=4)
  41.       'YResolution' => string '72/1' (length=4)
  42.       'ResolutionUnit' => int 2
  43.       'JPEGInterchangeFormat' => int 10570
  44.       'JPEGInterchangeFormatLength' => int 11304
  45.   'ExposureTime' => string '1/33' (length=4)
  46.   'FNumber' => string '22/10' (length=5)
  47.   'ExposureProgram' => int 2
  48.   'ISOSpeedRatings' => int 160
  49.   'ExifVersion' => string '0220' (length=4)
  50.   'DateTimeOriginal' => string '2015:10:29 16:05:28' (length=19)
  51.   'DateTimeDigitized' => string '2015:10:29 16:05:28' (length=19)
  52.   'ShutterSpeedValue' => string '506/100' (length=7)
  53.   'ApertureValue' => string '227/100' (length=7)
  54.   'BrightnessValue' => string '177/100' (length=7)
  55.   'ExposureBiasValue' => string '0/10' (length=4)
  56.   'MaxApertureValue' => string '227/100' (length=7)
  57.   'MeteringMode' => int 2
复制代码
参数说明:
  1. '文件名' => $infoAll['FileName'],
  2.             '文件修改时间' => date('Y:m:d H:i:s',$infoAll['FileDateTime']),
  3.             '文件大小' => round($infoAll['FileSize']/1024) . 'kb',
  4.             'Exif文件类型' => $this->getImgtype($imgPath,'Exif'),
  5.             'Mime文件类型' => $infoAll['MimeType'],
  6.             '找到Sections' => $infoAll['SectionsFound'],
  7.             'html中图片宽高' => $infoAll['html'],
  8.             '图片高度' => $infoAll['Height'] . 'px',
  9.             '图片宽度' => $infoAll['Width'] . 'px',
  10.             '是否彩色' => $infoAll['IsColor'] == 1 ? '是' : '否',
  11.             '是否为Motorola字节顺序' => $infoAll['ByteOrderMotorola'] == 1 ? '是' : '否',
  12.             '光圈数' => $infoAll['ApertureFNumber'],
  13.             '作者注释' => $infoAll['Comments'],
  14.             '作者' => $infoAll['Author'],
  15.             '用户注释' => $infoAll['UserComment'],
  16.             '用户注释编码' => $infoAll['UserCommentEncoding'],
  17.             '缩略图Exif文件类型' => $this->getImgtype($imgPath,'Exif'),
  18.             '缩略图Mime文件类型' => $infoAll['Thumbnail.MimeType'],
  19.             '制造商' => $infoAll['Make'],
  20.             '型号' => $infoAll['Model'],
  21.             '方向' => array_search($infoAll['Orientation'],array(
  22.                 'top left side' => 1,
  23.                 'top right side' => 2,
  24.                 'bottom right side' => 3,
  25.                 'bottom left side' => 4,
  26.                 'left side top' => 5,
  27.                 'right side top' => 6,
  28.                 'right side bottom' => 7,
  29.                 'left side bottom' => 8
  30.             )),
  31.             '水平分辨率' => $infoAll['XResolution'],
  32.             '垂直分辨率' => $infoAll['YResolution'],
  33.             '分辨率单位' => array_search($infoAll['ResolutionUnit'],array(
  34.                 '无单位' => 1,
  35.                 '英寸' => 2,
  36.                 '厘米' => 3
  37.             )),
  38.             '创建软件' => $infoAll['Software'],
  39.             '最后修改时间' => $infoAll['DateTime'],
  40.             'YCbCr位置控制' => $infoAll['YCbCrPositioning'] == 1 ? '像素阵列的中心' : '基准点',
  41.             'Exif图像IFD的指针' => $infoAll['Exif_IFD_Pointer'],
  42.             '压缩方式' => $infoAll['Compression'] == 6 ? 'jpeg压缩' : '无压缩',
  43.             'JPEG SOI偏移' => $infoAll['JPEGInterchangeFormat'],
  44.             'JPEG数据字节' => $infoAll['JPEGInterchangeFormatLength'],
  45.             '曝光时间' => $infoAll['ExposureTime'] . '秒',
  46.             '焦距比数' => $infoAll['FNumber'],
  47.             '曝光程序' => array_search($infoAll['ExposureProgram'],array(
  48.                 '手动控制' => 1,
  49.                 '程序控制' => 2,
  50.                 '光圈优先' => 3,
  51.                 '快门优先' => 4,
  52.                 '景深优先' => 5,
  53.                 '运动模式' => 6,
  54.                 '肖像模式' => 7,
  55.                 '风景模式' => 8
  56.             )),
  57.             'ISO感光度' => $infoAll['ISOSpeedRatings'],
  58.             'Exif版本' => $infoAll['ExifVersion'],
  59.             '拍摄时间' => $infoAll['DateTimeOriginal'],
  60.             '数字化时间' => $infoAll['DateTimeDigitized'],
  61.             '分量配置' => $infoAll['ComponentsConfiguration'],
  62.             '图像压缩率' => $infoAll['CompressedBitsPerPixel'],
  63.             '曝光补偿' => $infoAll['ExposureBiasValue'] . '电子伏特',
  64.             '最大光圈值' => $infoAll['MaxApertureValue'],
  65.             '测光模式' => array_search($infoAll['MeteringMode'],array(
  66.                 '未知' => 0,
  67.                 '平均' => 1,
  68.                 '中央重点平均测光' => 2,
  69.                 '点测' => 3,
  70.                 '分区' => 4,
  71.                 '评估' => 5,
  72.                 '局部' => 6,
  73.                 '其他' => 255
  74.             )),
  75.             '光源' => array_search($infoAll['LightSource'],array(
  76.                 '未知' => 0,
  77.                 '日光灯' => 1,
  78.                 '荧光灯' => 2,
  79.                 '钨丝灯' => 3,
  80.                 '闪光灯' => 10,
  81.                 '标准灯光A' => 17,
  82.                 '标准灯光B' => 18,
  83.                 '标准灯光C' => 19,
  84.                 'D55' => 20,
  85.                 'D65' => 21,
  86.                 'D75' => 22,
  87.                 '其他' => 255,
  88.             )),
  89.             '闪光灯' => array_search($infoAll['Flash'],array(
  90.                 '闪光灯未闪光' => 0,
  91.                 '闪光灯已闪光' => 1,
  92.                 '闪光灯已闪光但频闪观测器未检测到返回光源' => 5,
  93.                 '闪光灯已闪光,频闪观测器检测到返回光源' => 7
  94.             )),
  95.             '焦距' => $infoAll['FocalLength'] . '毫米',
  96.             '亚秒时间' => $infoAll['SubSecTime'],
  97.             '亚秒级拍摄时间' => $infoAll['SubSecTimeOriginal'],
  98.             '亚秒级数字化时间' => $infoAll['SubSecTimeDigitized'],
  99.             'FlashPix版本' => $infoAll['FlashPixVersion'],
  100.             '色彩空间' => $infoAll['ColorSpace'] == 1 ? 'sRGB' : 'Uncalibrated',
  101.             'Exif图片宽度' => $infoAll['ExifImageWidth'] . 'px',
  102.             'EXif图片高度' => $infoAll['ExifImageLength'] . 'px',
  103.             'IFD格式数据偏移量' => $infoAll['InteroperabilityOffset'],
  104.             '彩色区域传感器类型' => $infoAll['SensingMethod'] == 2 ? '单色区传感器' : '其他',
  105.             '图片像源' => $infoAll['FileSource'] == '0x03' ? '数码相机' : '其他',
  106.             '场景类型' => $infoAll['SceneType'] == '0x01' ? '直接拍摄' : '其他',
  107.             '滤波阵列图案' => $infoAll['CFAPattern'],
  108.             '自定义图像处理' => $infoAll['CustomRendered'],
  109.             '曝光模式' => $infoAll['CustomRendered'] == 1 ? '手动' : '自动',
  110.             '白平衡' => $infoAll['WhiteBalance'] == 1 ? '手动' : '自动',
  111.             '数位变焦倍率' => $infoAll['DigitalZoomRatio'],
  112.             '等价35mm焦距' => $infoAll['FocalLengthIn35mmFilm'] . '毫米',
  113.             '取景模式' => array_search($infoAll['SceneCaptureType'],array(
  114.                 '自动' => 0,
  115.                 '肖像场景' => 1,
  116.                 '景观场景' => 2,
  117.                 '运动场景' => 3,
  118.                 '夜景' => 4,
  119.                 '自动曝光' => 5,
  120.                 '光圈优先自动曝光' => 256,
  121.                 '快门优先自动曝光' => 512,
  122.                 '手动曝光' => 768,
  123.             )),
  124.             '增益控制' => $infoAll['GainControl'],
  125.             '对比度' => array_search($infoAll['Contrast'],array(
  126.                 '低' => -1,
  127.                 '普通' => 0,
  128.                 '高' => 1
  129.             )),
  130.             '饱和度' => array_search($infoAll['Saturation'],array(
  131.                 '低' => -1,
  132.                 '普通' => 0,
  133.                 '高' => 1
  134.             )),
  135.             '清晰度' => array_search($infoAll['Sharpness'],array(
  136.                 '低' => -1,
  137.                 '普通' => 0,
  138.                 '高' => 1
  139.             )),
  140.             '对焦距离' => array_search($infoAll['SubjectDistanceRange'],array(
  141.                 '未知' => 0,
  142.                 '微距' => 1,
  143.                 '近景' => 2,
  144.                 '远景' => 3
  145.             )),
  146.             'InterOperability指数' => $infoAll['InterOperabilityIndex'],
  147.             'InterOperability版本' => $infoAll['InterOperabilityVersion']
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|PHPIN.NET ( 冀ICP备12000898号-14 )|网站地图

GMT+8, 2024-4-25 12:57

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表