歡迎光臨, 訪客. 請先 登入註冊一個帳號.
三月 29, 2024, 12:32:12 上午
19595 文章 在 3865 主題 由 4580 會員
最新註冊會員: aa123aa1
LifeType 中文開發論壇  |  開發  |  模版設計  |  圖片EXIF資訊問題 « 上篇主題 下篇主題 »
頁: [1]
作者 主題: 圖片EXIF資訊問題  (閱讀 9463 次)
tzung.shium
新手見習
*
文章: 3


檢視個人資料
« 於: 八月 23, 2007, 09:09:52 上午 »

我想要能夠在搜尋欄位裡面能夠搜尋到圖片的EXIF資訊!!讓收尋文件不只是只能搜尋文章也可以搜尋圖片!!
請問這樣是有可能的嗎!! 如果可以 請指點我一條明路!!
已記錄
tzung.shium
新手見習
*
文章: 3


檢視個人資料
« 回覆文章 #1 於: 八月 27, 2007, 10:54:10 上午 »

我已經找到圖片偵測EXIF資訊問題  請問一下 我該如何寫入資料庫  能讓PLOG網頁能夠搜尋出來在展示在首頁頁面像搜尋文章一樣

假設 我有一張圖片 它的焦長: 5.8mm 我只要在搜尋上面打上5.8 或焦長
搜尋頁面就能夠把有關 焦長: 5.8mm  圖片跟資訊顯示出來



<body bgcolor='#cccccc'>
<center>
<a href=index.html>回首頁</a><br><br><br>
<?
global $files_array;
$files_array= array();
$epaper_path = "$dd/";

$readmefile=$epaper_path."readme.txt";

if ( $fp=@file($readmefile)) {
  $fp=file($readmefile);
  }  ;

echo "<H1>".$fp[0]."</h1><br>";

if ($dh = opendir($epaper_path)) { //打開資料夾
  $files = array(); //將變數$files設定成陣列
  while (($file = readdir($dh)) !== false) { //先設一個陣列變數 等等資料夾裡面所有檔名當丟進去這個陣列
   if ((substr($file, strlen($file) - 4) == '.jpg') or (substr($file, strlen($file) - 4) == '.JPG')) {

       array_push($files, $file);
     }
  }
  closedir($dh);
}

sort($files); //將陣列排序整理一下
$ss=1;
foreach ($files as $file){ //將檔名輸出
  $title = Title($file);
//include(''); // 頁首
echo "<table border=0 align=center cellpadding=2 cellspacing=2><tr><td align=center>";

//              echo "<table border=0 cellpadding=1 cellspacing=1><tr><th>";
              //  echo "<img src='/images/dot_l2.gif' width='14' height='14' align='absmiddle'>";
echo "<font color='#ff6600'><b>[#".$ss."]".$fp[$ss]."</b></font>";
echo "</td></tr><tr><td align=center>";
echo "<img src=$dd"."/{$file} alt='$file' border='1'>";
echo showEXIF($dd."/".$file);
echo "<br><br>檔案夾吸血蝙蝠<b>$dd</b>]-檔名吸血蝙蝠<b>$file</b>]<br><br><br>";
      
echo "</td></tr><tr><td align=center>";
echo "</td></tr>";
echo "</table><br>";
$ss++;
}
 
echo "<H1>".$fp[$ss]."</h1><br>";
//------------------處理檔案名稱--------------------------
function Title($filename) {
  $title = substr($filename, 0, strlen($filename) - 4);
  $title = str_replace('-', ' ', $title);
  $title = ucwords($title);
  return $title;
}
echo "<a href=index.html>回首頁</a>";


//------------------處理EXIF--------------------------
function showEXIF($path){
                                if (function_exists('read_exif_data')){
                                        $exif = @read_exif_data($path,0,true);
                    if ($exif['EXIF']['ExifVersion']){
                            $nodata="<FONT STYLE=\"color:gray;font:8pt Arial\">N/A</FONT>";
                                                $attach_exif ="<SPAN STYLE=\"height:1px;margin:1px 0 8px;border:0;font:8pt/120% 'MS Gothic',Tahoma;color:#005000\"><FONT STYLE=\"color:black;font:8pt 'MS Gothic'\">EXIF ".sprintf("%1.2f",(float)$exif['EXIF']['ExifVersion']/100)." - </FONT><SPAN STYLE=\"border-bottom:1px solid #0080C0;height:1px;margin:0;padding:2px 0 0 0\">";
                                                $attach_exif.="<FONT STYLE=\"font-family:Tahoma;color:black\">".$exif['IFD0']['Model']."</FONT> &nbsp;";
                                                if(empty($exif['EXIF']['ExposureProgram']))$exif['EXIF']['ExposureProgram']=$nodata;
                                                else{
                                                        switch($exif['EXIF']['ExposureProgram']){
                                                                case 1:$exif['EXIF']['ExposureProgram'] = "手動(M)";break;//Manual Control
                                                                case 2:$exif['EXIF']['ExposureProgram'] = "程式自動(P)";break;//Program Normal
                                                                case 3:$exif['EXIF']['ExposureProgram'] = "光圈先決(A)";break;//Aperture Priority
                                                                case 4:$exif['EXIF']['ExposureProgram'] = "快門先決(S)";break;//Shutter Priority
                                                                case 5:$exif['EXIF']['ExposureProgram'] = "慢速快門";break;//Program Creative (Slow Program)
                                                                case 6:$exif['EXIF']['ExposureProgram'] = "運動模式";break;//Program Action(High-Speed Program)
                                                                case 7:$exif['EXIF']['ExposureProgram'] = "人像";break;//Portrait
                                                                case 8:$exif['EXIF']['ExposureProgram'] = "風景";//Landscape
                                                        }
                                                }
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\">曝光模式:</FONT>".$exif['EXIF']['ExposureProgram'];
                                                if(empty($exif['EXIF']['MeteringMode']))$exif['EXIF']['MeteringMode']=$nodata;
                                                else{
                                                        switch($exif['EXIF']['MeteringMode']){
                                                                case 0 :$exif['EXIF']['MeteringMode'] = "未知";break;
                                                                case 1 :$exif['EXIF']['MeteringMode'] = "Average";break;
                                                                case 2 :$exif['EXIF']['MeteringMode'] = "中央重點測光";break;
                                                                case 3 :$exif['EXIF']['MeteringMode'] = "點測光";break;
                                                                case 4 :$exif['EXIF']['MeteringMode'] = "多重點測光";break;
                                                                case 5 :$exif['EXIF']['MeteringMode'] = "Multi-Segment";break;
                                                                case 6 :$exif['EXIF']['MeteringMode'] = "Partial";break;
                                                                case 255:$exif['EXIF']['MeteringMode'] = "其它";break;
                                                        }
                                                }
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;測光:</FONT>".$exif['EXIF']['MeteringMode']."";
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;白平衡:</FONT>".$exif['EXIF']['WhiteBalance']."</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN STYLE=\"height:1px;margin:0;padding:2px 0 0 0\">";
                                                if(empty($exif['COMPUTED']['ApertureFNumber']))$exif['COMPUTED']['ApertureFNumber']=$nodata;
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\">光圈:</FONT>".ereg_replace("f/","F",$exif['COMPUTED']['ApertureFNumber'])."";
                                                if(empty($exif['EXIF'][ExposureTime])){
                                                        $exif['EXIF'][ExposureTime]=$nodata;
                                                }else{
                                                        $exif['EXIF'][ExposureTime]=explode("/",$exif['EXIF'][ExposureTime]);
                                                        if(($exif['EXIF'][ExposureTime][0]/$exif['EXIF'][ExposureTime][1])>=1)
                                                                $exif['EXIF'][ExposureTime]=sprintf("%.1f Sec",(float)$exif['EXIF'][ExposureTime][0]/$exif['EXIF'][ExposureTime][1]);
                                                        else
                                                                $exif['EXIF'][ExposureTime]=sprintf("1/%d Sec",$exif['EXIF'][ExposureTime][1]/$exif['EXIF'][ExposureTime][0]);
                                                }
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;快門:</FONT>".$exif['EXIF'][ExposureTime]."";
                                                if(empty($exif['EXIF'][ISOSpeedRatings]))$exif['EXIF'][ISOSpeedRatings]=$nodata;
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;ISO:</FONT>".$exif['EXIF'][ISOSpeedRatings]."";
                                                if(empty($exif['EXIF'][ExposureBiasValue])){
                                                        $exif['EXIF'][ExposureBiasValue]=$nodata;
                                                }else{
                                                        $exif['EXIF'][ExposureBiasValue]=explode("/",$exif['EXIF'][ExposureBiasValue]);
                                                        $exif['EXIF'][ExposureBiasValue]=sprintf("%1.1f EV",((float)$exif['EXIF'][ExposureBiasValue][0]/$exif['EXIF'][ExposureBiasValue][1]*100)/100);
                                                        if((float)$exif['EXIF'][ExposureBiasValue]>0)$exif['EXIF'][ExposureBiasValue]="+".$exif['EXIF'][ExposureBiasValue];
                                                }
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;曝光補償:</FONT>".$exif['EXIF'][ExposureBiasValue]."";
                                                if(empty($exif['EXIF'][FocalLength])){
                                                        $exif['EXIF'][FocalLength]=$nodata;
                                                }else{
                                                        $exif['EXIF'][FocalLength]=explode("/",$exif['EXIF'][FocalLength]);
                                                        $exif['EXIF'][FocalLength]=sprintf("%4.1fmm",(double)$exif['EXIF'][FocalLength][0]/$exif['EXIF'][FocalLength][1]);
                                                }
                                                $attach_exif.="<FONT STYLE=\"color:black;font:8pt 'MS Gothic'\"> &nbsp;焦長:</FONT>".$exif['EXIF'][FocalLength]."</SPAN></SPAN>";
                    }
                }
                return $attach_exif;
}
?>
已記錄
tzung.shium
新手見習
*
文章: 3


檢視個人資料
« 回覆文章 #2 於: 八月 27, 2007, 04:24:56 下午 »

我研究結果發現 在檔案中心上傳檔案後會出現圖片資訊  如果可以把function showEXIF($path) 函數一起加進去
那顯示的資訊會更多!!

問題一: 請問一下  寫入檔案資訊的頁面在哪 ??
問題二:能否在searchresults.template 裡面加上搜尋檔案資訊的功能

繼續努力研究!!

已記錄
頁: [1]
LifeType 中文開發論壇  |  開發  |  模版設計  |  圖片EXIF資訊問題 « 上篇主題 下篇主題 »
    前往: