Programming Life
相信不能相信的,完成不能完成的。矛盾,就象征进步。
posts - 151,comments - 7,trackbacks - 0
这个插件最早是由JackMing发布在freediscuz上的for discuz 2.0版本,后来我将他更新至2.5 sp1版本,现移植至for D4.x和D5版,其实移植过程无需太多修改,为了方便需要的朋友,我重新整理下,如有错误希望原作者和使用过的朋友指正。

9月14号
现发现有未解决的问题:
1,开了水印功能便无法显示EXIF信息,有网友好像有了解决方案,本人最近比较忙,望能补充完善他。
2,下载附件来路检查功能开启有时会失效
3,无法在UTF8版本中使用,会乱码
4,有可能不支持php5,此条暂时有待证实

+++++++++++++++++++++++++
HACK名稱: 显示数码图片的EXIF信息
適用版本: discuz!5
原作者: JackMing  (老么 修改移植至 for D5版本)
修改文件: viewthread.php
修改模板: viewthread.htm
+++++++++++++++++++++++++

安装步骤

1、修改文件viewthread.php

查找:$postlist[$attach['pid']]['attachments'][$attach['aid']]

在前面填入:
/*--------------------------------
                显示jpeg和tiff图片的EXIF信息
*/

                
if (($extension == 'jpg' || $extension == 'jpeg'&& function_exists

(
'read_exif_data')){
                    
$exif = @read_exif_data($discuz_root."./attachments/".$attach

[attachment]
,0,true);
                    
if ($exif['EXIF']['ExifVersion']){
                    
$attach['exif']="EXIF版本:".$exif['EXIF']['ExifVersion'].
" 相机品牌:".$exif['IFD0']['Make'].
" 相机型号:".$exif['IFD0']['Model'].
" 光圈:".$exif['COMPUTED']['ApertureFNumber'].
" 快门:".$exif['EXIF']['ExposureTime'].
" 感光度ISO:".$exif['EXIF']
[ISOSpeedRatings];
                    }
                }
                
/*-------------------------------*/

2、修改模版viewthread.htm
FOR D4.x
查找:
<img src="$attachurl/$attach[attachment]" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='{lang image_open_zoom}';}" onmouseover="if(this.resized) this.style.cursor='hand';" onclick="if(!this.resized) {return false;} else {window.open('$attachurl/$attach[attachment]');}" onmousewheel="return imgzoom(this);">

后面填入:<br>$attach['exif']
注意:
本hack主要利用了read_exif_data函数,该函数是不用gd库的,但是在默认情况下这个函数是无法使用的,打开该函数的方法如下:
UNIX/LINUX:编译PHP的时候,应该加上 --enable-exif选项,
Windows: 
1、在PHP.ini里面,找到 ;extension=php_exif.dll 去掉分号。
2、找到[exif]段,把下面语句的分号去掉。
;exif
.encode_unicode = ISO-8859-15
;exif
.decode_unicode_motorola = UCS-2BE
;exif
.decode_unicode_intel    = UCS-2LE
;exif
.encode_jis = 
;exif
.decode_jis_motorola = JIS
;exif
.decode_jis_intel    = JIS

对于大部分jpg图片都是没有可用的EXIF信息的,除非是最近的数码作品。

最后提供点参数给有特殊需求的专业人士:(以下加入的格式可参照修改viewthread.php中的基本格式)
"文件名"                =>        $exif[FILE][FileName], 
"文件类型"                =>        $imgtype[$exif[FILE][FileType]], 
文件格式
"                =>        $exif[FILE][MimeType], 
"文件大小"                =>        $exif[FILE][FileSize], 
"时间戳"                =>        date("Y-m-d H:i:s",$exif[FILE][FileDateTime]), 
"图片说明"                =>        $exif[IFD0][ImageDescription], 
"制造商"                =>        $exif[IFD0][Make], 
"型号"                =>        $exif[IFD0][Model], 
"方向"                =>        $Orientation[$exif[IFD0][Orientation]], 
"水平分辨率"        =>        $exif[IFD0][XResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], 
"垂直分辨率"        =>        $exif[IFD0][YResolution].$ResolutionUnit[$exif[IFD0][ResolutionUnit]], 
"创建软件"                =>        $exif[IFD0][Software], 
"修改时间"                =>        $exif[IFD0][DateTime], 
"作者"                        =>        $exif[IFD0][Artist], 
"YCbCr位置控制"        =>        $YCbCrPositioning[$exif[IFD0][YCbCrPositioning]], 
"版权"                        =>        $exif[IFD0][Copyright], 
"摄影版权"                =>        $exif[COMPUTED][Copyright.Photographer], 
"编辑版权"                =>        $exif[COMPUTED][Copyright.Editor], 
"Exif版本"                =>        $exif[EXIF][ExifVersion], 
"FlashPix版本"        =>        "Ver. ".number_format($exif[EXIF][FlashPixVersion]/100,2), 
"拍摄时间"                =>        $exif[EXIF][DateTimeOriginal], 
"数字化时间"        =>        $exif[EXIF][DateTimeDigitized], 
"拍摄分辨率高"        =>        $exif[COMPUTED][Height], 
"拍摄分辨率宽"        =>        $exif[COMPUTED][Width], 
"光圈"                        =>        $exif[EXIF][ApertureValue], 
"快门速度"                =>        $exif[EXIF][ShutterSpeedValue], 
"快门光圈"                =>        $exif[COMPUTED][ApertureFNumber], 
"最大光圈值"        =>        "F".$exif[EXIF][MaxApertureValue], 
"曝光时间"                =>        $exif[EXIF][ExposureTime], 
"F-Number"                =>        $exif[EXIF][FNumber], 
"测光模式"                =>        GetImageInfoVal($exif[EXIF][MeteringMode],$MeteringMode_arr), 
"光源"                        =>        GetImageInfoVal($exif[EXIF][LightSource], $Lightsource_arr), 
"闪光灯"                =>        GetImageInfoVal($exif[EXIF][Flash], $Flash_arr), 
"曝光模式"                =>        ($exif[EXIF][ExposureMode]==1?"手动":"自动"), 
"白平衡"                =>        ($exif[EXIF][WhiteBalance]==1?"手动":"自动"), 
"曝光程序"                =>        $ExposureProgram[$exif[EXIF][ExposureProgram]], 
"曝光补偿"                =>        $exif[EXIF][ExposureBiasValue]."EV"
"ISO感光度"                =>        $exif[EXIF][ISOSpeedRatings], 
"分量配置"                =>        (bin2hex($exif[EXIF][ComponentsConfiguration])=="01020300"?"YCbCr":"RGB"),//'0x04,0x05,0x06,0x00'="RGB" '0x01,0x02,0x03,0x00'="YCbCr" 
"图像压缩率"        =>        $exif[EXIF][CompressedBitsPerPixel]."Bits/Pixel"
"对焦距离"                =>        $exif[COMPUTED][FocusDistance]."m"
"焦距"                        =>        $exif[EXIF][FocalLength]."mm"
"等价35mm焦距"        =>        $exif[EXIF][FocalLengthIn35mmFilm]."mm"
posted on 2008-01-01 04:27 Prog 阅读(590) 评论(0)  编辑 收藏 引用 网摘 所属分类: PHP

只有注册用户登录后才能发表评论。
网站导航: