国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

顯示照片exif信息PHP代碼

2024-05-04 23:04:15
字體:
來源:轉載
供稿:網友
中文方式顯示照片exif信息,顯示圖片中所略圖

這東西除了一些php論壇簡單顯示三兩信息,別人的lb5000論壇上看到過顯示,asp的也有不過很久沒接觸看著暈。

不想重復勞動,搜過google,除了asp沒找到其他開源的顯示exif的,所以整理出來或許有用。

沒什么技術含量,基本只是漢化和資料整理的工作,以下代碼為主要部分,所有文件在壓縮包內,可以廣泛用于相冊和論壇顯示圖片信息的插件,希望熟悉相關知識的朋友找找bug或者加以優化。

目前應該缺不少信息,如果單單使用應該足夠了。

——————————————————
看到過別人傳過來的照片里面有縮略圖,photoshop做的,但是不知道怎么加進去,有人知道么

縮略圖可以顯示:)


php代碼:--------------------------------------------------------------------------------

<?
/**
* 獲取圖象信息的函數
*
* 一個全面獲取圖象信息的函數
*
* @access public
* @param string $img 圖片路徑
* @return array
*/
function getimageinfoval($imageinfo,$val_arr) {
    $infoval    =    "未知";
    foreach($val_arr as $name=>$val) {
        if ($name==$imageinfo) {
            $infoval    =    &$val;
            break;
        }
    }
    return $infoval;
}
function getimageinfo($img) {
   

   
    $imgtype            =    array("", "gif", "jpg", "png", "swf", "psd", "bmp", "tiff(intel byte order)", "tiff(motorola byte order)", "jpc", "jp2", "jpx", "jb2", "swc", "iff", "wbmp", "xbm");
    $orientation        =    array("", "top left side", "top right side", "bottom right side", "bottom left side", "left side top", "right side top", "right side bottom", "left side bottom");
    $resolutionunit        =    array("", "", "英寸", "厘米");
    $ycbcrpositioning    =    array("", "the center of pixel array", "the datum point");
    $exposureprogram    =    array("未定義", "手動", "標準程序", "光圈先決", "快門先決", "景深先決", "運動模式", "肖像模式", "風景模式");
    $meteringmode_arr    =    array(
        "0"        =>    "未知",
        "1"        =>    "平均",
        "2"        =>    "中央重點平均測光",
        "3"        =>    "點測",
        "4"        =>    "分區",
        "5"        =>    "評估",
        "6"        =>    "局部",
        "255"    =>    "其他"
        );
    $lightsource_arr    =    array(
        "0"        =>    "未知",
        "1"        =>    "日光",
        "2"        =>    "熒光燈",
        "3"        =>    "鎢絲燈",
        "10"    =>    "閃光燈",
        "17"    =>    "標準燈光a",
        "18"    =>    "標準燈光b",
        "19"    =>    "標準燈光c",
        "20"    =>    "d55",
        "21"    =>    "d65",
        "22"    =>    "d75",
        "255"    =>    "其他"
        );
    $flash_arr            =    array(
        "0"        =>    "flash did not fire",
        "1"        =>    "flash fired",
        "5"        =>    "flash fired but strobe return light not detected",
        "7"        =>    "flash fired and strobe return light detected",
        );
   
    $exif = exif_read_data ($img,"ifd0");
    if ($exif===false) {
        $new_img_info    =    array ("文件信息"        =>    "沒有圖片exif信息");
    }
    else
    {
        $exif = exif_read_data ($img,0,true);
        $new_img_info    =    array (
            "文件信息"        =>    "-----------------------------",
            "文件名"        =>    $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],
            /*
            the actual aperture value of lens when the image was taken.
            unit is apex.
            to convert this value to ordinary f-number(f-stop),
            calculate this value's power of root 2 (=1.4142).
            for example, if the aperturevalue is '5', f-number is pow(1.41425,5) = f5.6.
            */
            "光圈"            =>    $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]],
            /*
            brightness of taken subject, unit is apex. to calculate exposure(ev) from brigtnessvalue(bv), you must add sensitivityvalue(sv).
            ev=bv+sv   sv=log((isospeedrating/3.125),2)
            iso100:sv=5, iso200:sv=6, iso400:sv=7, iso125:sv=5.32.
            */
            "曝光補償"        =>    $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",
            /*
            stores user comment. this tag allows to use two-byte character code or unicode. first 8 bytes describe the character code. 'jis' is a japanese character code (known as kanji).
            '0x41,0x53,0x43,0x49,0x49,0x00,0x00,0x00':ascii
            '0x4a,0x49,0x53,0x00,0x00,0x00,0x00,0x00':jis
            '0x55,0x4e,0x49,0x43,0x4f,0x44,0x45,0x00':unicode
            '0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00':undefined
            */
            "用戶注釋編碼"    =>    $exif[computed][usercommentencoding],
            "用戶注釋"        =>    $exif[computed][usercomment],
            "色彩空間"        =>    ($exif[exif][colorspace]==1?"srgb":"uncalibrated"),
            "exif圖像寬度"    =>    $exif[exif][exifimagelength],
            "exif圖像高度"    =>    $exif[exif][exifimagewidth],
            "文件來源"        =>    (bin2hex($exif[exif][filesource])==0x03?"digital still camera":"unknown"),
            "場景類型"        =>    (bin2hex($exif[exif][scenetype])==0x01?"a directly photographed image":"unknown"),
            "縮略圖文件格式"    =>    $exif[computed][thumbnail.filetype],
            "縮略圖mime格式"    =>    $exif[computed][thumbnail.mimetype]
        );
    }
    return $new_img_info;
}

$innerhtml    =    "";
$exif    =    getimageinfo($_get['img']);
$innerhtml    .=    "<table>";

foreach($exif as $name=>$val) {
    $innerhtml    .=    "<tr><td>{$name}</td><td>{$val}</td></tr>";
}

$innerhtml    .=    "<tr><td colspan=/"2/">";
if ($_get['img']) {
    $image = exif_thumbnail($_get['img']);
} else {
    $image = false;
}
if ($image!==false) {
    $innerhtml    .=    "<img src=/"thumbnail.php?img=".$_get['img']."/">";
} else {
    // no thumbnail available, handle the error here
    $innerhtml    .=    "no thumbnail available";
}

$innerhtml    .=    "</td></tr></table>";
?>
<html>
<head>
<title>圖片信息</title>
<meta http-equiv="content-type" content="text/html; charset=??????">
</head>
<body>
<script>
<!--
//初始化內容值
parent.followtd<?=$_get['r_id'];?>.innerhtml='<?=$innerhtml;?>';
//已讀取
parent.document.images.followimg<?=$_get['r_id'];?>.loaded='yes';
-->
</script>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长丰县| 凭祥市| 长宁县| 诏安县| 厦门市| 黑水县| 西丰县| 五家渠市| 扶余县| 大安市| 海淀区| 高雄市| 施甸县| 隆安县| 丹阳市| SHOW| 丰都县| 南涧| 文登市| 梁河县| 静乐县| 南宫市| 通道| 丘北县| 宝丰县| 灵川县| 临安市| 台南县| 青川县| 镇平县| 海林市| 洪泽县| 福清市| 清涧县| 南充市| 麻江县| 察隅县| 泸溪县| 社旗县| 扎鲁特旗| 和田市|