php exif_read_data读取图片exif信息部全

allen0228 2009-06-16 02:39:29
下面是在linux环境下
$exif = exif_read_data('test.jpg', "IFDO", false);
var_dump($exif);
读取的信息如下:
array(16) { ["FileName"]=> string(8) "test.jpg" ["FileDateTime"]=> int(1245132764) ["FileSize"]=> int(1136412) ["FileType"]=> int(2) ["MimeType"]=> string(10) "image/jpeg" ["SectionsFound"]=> string(26) "ANY_TAG, IFD0, EXIF, WINXP" ["COMPUTED"]=> array(5) { ["html"]=> string(26) "width="1680" height="1050"" ["Height"]=> int(1050) ["Width"]=> int(1680) ["IsColor"]=> int(1) ["ByteOrderMotorola"]=> int(0) } ["Software"]=> string(19) "Adobe Photoshop 7.0" ["DateTime"]=> string(19) "2006:05:10 11:30:17" ["Exif_IFD_Pointer"]=> int(268) ["Title"]=> string(1) "4" ["Comments"]=> string(1) "W" ["Author"]=> string(1) "M" ["ColorSpace"]=> int(65535) ["ExifImageWidth"]=> int(5061) ["ExifImageLength"]=> int(3481) }


["Title"]=> string(1) "4" ["Comments"]=> string(1) "W" ["Author"]=> string(1) "M"

图片中对应的内容分别是:
400232
MATTIAS KLUM
Water lily (Nymphaea sp.).Location: SWEDEN.

同样的代码在winxp中是有用的
为何在linux中无效

希望大家能帮我解决
...全文
385 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
allen0228 2009-06-21
  • 打赏
  • 举报
回复
问题被我解决了 用了hack方式 唉 真想有好的办法解决
allen0228 2009-06-20
  • 打赏
  • 举报
回复
自己顶一下
allen0228 2009-06-16
  • 打赏
  • 举报
回复
怎么没有人啊 这个问题解决了
$exif = @exif_read_data($file, O, true);
foreach ($exif as $key => $section){
if($key == 'IFD0'){
foreach ($section as $name => $val) {
if($name == 'DateTime' && $val != ''){
$this->DateTime = HtmlEncode(trim($val));
}
else if($name == 'Title' && $val != ''){
$this->Title = HtmlEncode(trim($val));
}
else if($name == 'Comments' && $val!= ''){
$this->Comments = HtmlEncode(trim($val));
}
else if($name == 'Author' && $val != ''){
$this->Author = HtmlEncode(trim($val));
}
}
}
}


function HtmlEncode($str){
$TempStr=trim($str);
$TempStr=htmlentities($TempStr,ENT_QUOTES);
return $TempStr;
}



可是将得到的数据插入到数据库当中的时候 然后再取数据的时候
就会出错 只能取到数据的第一个字符
不知道为何
allen0228 2009-06-16
  • 打赏
  • 举报
回复
再次描述:
["Title"]=> string(1) "4" ["Comments"]=> string(1) "W" ["Author"]=> string(1) "M"

图片中对应的内容分别是:
400232
Water lily (Nymphaea sp.).Location: SWEDEN.
MATTIAS KLUM

每次读 出来的内容刚好是第一个字母 为何

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧