主页 M

纯洁MM教你提取相片中的详细参数:相机品牌,色彩编码,拍摄时间,GPS等等近50项信息

2014-05-26 网页编程网 网页编程网

也就是exif信息,你觉得可怕吗?一般此信息放置在jpeg/tief文件夹的头部,我们要怎么获得呢?如下:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>

<body>
<p>要先修改php.ini文件,共二点:第一,extension=php_exif.dll去了;号。第二,的存储位置,必须放置在php_mbstring.dll后面。</p>
<?php
function getExif($img){
  $exifTest=exif_read_data($img,'IFD0');
  
  if($exifTest===false){
    exit("No header data found.<br />");
  }

  $exif =exif_read_data($img,0,true);
  foreach ($exif as $key => $section){
    foreach ($section as $name => $val){
      echo "$key.$name: $val<br />\n";
    }
  }
}

echo getExif('qykx/images/bg1.jpg');
?> 
</body>
</html>

运行以后,将得到如下信息:

FILE.FileName: bg1.jpg
FILE.FileDateTime: 1237004680
FILE.FileSize: 2933959
FILE.FileType: 2
FILE.MimeType: image/jpeg
FILE.SectionsFound: ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP, MAKERNOTE
COMPUTED.html: width="3264" height="2448"
COMPUTED.Height: 2448
COMPUTED.Width: 3264
COMPUTED.IsColor: 1
COMPUTED.ByteOrderMotorola: 0
COMPUTED.CCDWidth: 5mm
COMPUTED.ApertureFNumber: f/4.0
COMPUTED.UserComment: 
COMPUTED.UserCommentEncoding: UNDEFINED
COMPUTED.Thumbnail.FileType: 2
COMPUTED.Thumbnail.MimeType: image/jpeg
IFD0.Make: Canon
IFD0.Model: Canon PowerShot SX100 IS
IFD0.Orientation: 1
IFD0.XResolution: 180/1
IFD0.YResolution: 180/1
IFD0.ResolutionUnit: 2
IFD0.DateTime: 2009:03:14 12:24:40
IFD0.YCbCrPositioning: 1
IFD0.Exif_IFD_Pointer: 196
THUMBNAIL.Compression: 6
THUMBNAIL.XResolution: 180/1
THUMBNAIL.YResolution: 180/1
THUMBNAIL.ResolutionUnit: 2
THUMBNAIL.JPEGInterchangeFormat: 5108
THUMBNAIL.JPEGInterchangeFormatLength: 6250
EXIF.ExposureTime: 1/160
EXIF.FNumber: 40/10
EXIF.ISOSpeedRatings: 80
EXIF.ExifVersion: 0220
EXIF.DateTimeOriginal: 2009:03:14 12:24:40
EXIF.DateTimeDigitized: 2009:03:14 12:24:40
EXIF.ComponentsConfiguration: 
EXIF.CompressedBitsPerPixel: 3/1
EXIF.ShutterSpeedValue: 234/32
EXIF.ApertureValue: 128/32
EXIF.ExposureBiasValue: 0/3
EXIF.MaxApertureValue: 95/32
EXIF.MeteringMode: 5
EXIF.Flash: 16
EXIF.FocalLength: 6000/1000
EXIF.MakerNote: 0hp"x?Ȅ脀Ű?   ? )p&0?? E "Ѐ? #J $NR %'? Ѐ-`?@?`갗胟݀??????p怭D

阅读原文
阅读 3289
123 显示电脑版