EXIF 사진정보 보기 > Web Development

본문 바로가기
  • kb@lovelet.com
사이트 내 전체검색

RESOURCES Web Development

EXIF 사진정보 보기

페이지 정보

본문

(중얼중얼 : Canon 400D를 사고 사진을 올리며 EXIF 정보를 함께 올리려 하니 여간 짜증나는 일이 아니다.
해서 function으로 하나 만들어 봤다. 이미지 업로드 하면 자동으로 썸네일 만들고 해당 EXIF 정보를 보여줄 수 있도록 만들고 있는 중...)


혹시라도 필요한 분들이 있으면 가져다 쓰세욤~

<?php
/***************************************************************************
# Module Name : getExifInfo
# Author : Young-sick.Yoon (wizard@ncafe.net)
# Date : 2008-01-21 오후 4:19
# Information : EXIF Viewer (php)
***************************************************************************/

function getExifInfo($filename,$debug=0
) {
$exposureMode = array('Auto Exposure','Manual Exposure','Auto Bracket'
);
$exposureProgram = array("Not defined","Manual","Program (Auto)","Aperture priority","Shutter priority","Creative program","Action program","Portrait mode","Landscape mode"
);
$whiteBalance = array("Auto WB","Manual WB"
);
$meteringMode = array("Unknown","Average","CenterWeightedAverage","Spot","MultiSpot","Multi-segment","Partial"
);
$flash = array("73"=>"On Compulsory Red-eye reduction","89"=>"On Auto Red-eye reduction","95"=>"On Auto Red-eye reduction"
);

$erdata = @exif_read_data($filename,0,true
);
if (!
$erdata||!$erdata["EXIF"
]) { return; }

$exif["Make"] = $erdata["IFD0"]["Make"];
// 제조사
$exif["Model"] = $erdata["IFD0"]["Model"];
// 모델
$exif["ExifVersion"] = $erdata["EXIF"]["ExifVersion"];
// EXIF 버전
$exif["DateTime"] = $erdata["EXIF"]["DateTimeOriginal"];
// 촬영일
$exif["Software"] = $erdata["IFD0"]["Software"];
// 사용 Software
$exif["Width"] = $erdata["EXIF"]["ExifImageWidth"];
// 사진 크기
$exif["Height"] = $erdata["EXIF"]["ExifImageLength"];
// 사진 크기

$exif["ExposureMode"] = $exposureMode[$erdata["IFD0"]["ExposureMode"]];
// 노출모드
if (!$exif["ExposureMode"]) { $exif["ExposureMode"] = $exposureMode[$erdata["EXIF"]["ExposureMode"
]]; }

$tmp = explode("/",$erdata["EXIF"]["ExposureTime"]);
// 노출시간 (셔터스피드)
$exif["ExposureTime"] = $tmp[0]/$tmp[0]."/".$tmp[1]/$tmp[0]."s"
;
$tmp=null
;

$tmp = explode("/",$erdata["EXIF"]["FNumber"]);
// 조리개값
$exif["FNumber"] = "F".sprintf("%3.1f",@($tmp[0]/$tmp[1
]));
$tmp=null
;

$exif["ISO"] = "ISO-".$erdata["EXIF"]["ISOSpeedRatings"];
// ISO 감도
$exif["ExposureProgram"] = $exposureProgram[$erdata["EXIF"]["ExposureProgram"
]];

$exif["WhiteBalance"] = $whiteBalance[$erdata["IFD0"]["WhiteBalance"]];
// 화이트벨런스
if (!$exif["WhiteBalance"]) { $exif["WhiteBalance"] = $whiteBalance[$erdata["EXIF"]["WhiteBalance"
]]; }


$tmp = explode("/",$erdata["EXIF"]["ExposureBiasValue"]);
// 노출보정
$exif["ExposureBias"] = sprintf("%4.2f",@($tmp[0]/$tmp[1]))."EV"
;
$tmp=null
;

$exif["MeteringMode"] = $meteringMode[$erdata["EXIF"]["MeteringMode"]];
// 측광모드

if ($flash[$erdata["EXIF"]["Flash"]]) { $flash_str = " (".$flash[$erdata["EXIF"]["Flash"]].")"; }
// 플래시사용여부
$exif["Flash"] = @($erdata["EXIF"]["Flash"]&7)>0?"Flash fired":"Flash not fired"
;

$tmp = explode("/",$erdata["EXIF"]["FocalLength"]);
// 초점거리
$exif["FocalLength"] = @($tmp[0]/$tmp[1])."mm"
;
$tmp=null
;

$tmp = (int)$erdata["COMPUTED"]["CCDWidth"];
// CCD
if ($tmp>0
) {
$exif["CCDWidth"] = $tmp."mm"
;
}
$tmp=null
;

$exif["FocalLengthIn35mmFilm"] = $erdata["EXIF"]["FocalLengthIn35mmFilm"]." mm";
// 35인치 환산값
$exif["DigitalZoomRatio"] = $erdata["EXIF"]["DigitalZoomRatio"];
// 줌
$exif["FirmwareVersion"] = $erdata["MAKERNOTE"]["FirmwareVersion"];
// 펌웨어 버전
$exif["Lens"] = $erdata["MAKERNOTE"]["UndefinedTag:0x0095"];
// 사용랜즈 Canon Body & Canon Lens Only

while(list($k,$v)=each($exif
)) {
if (
$v&&trim($v)!="F"&&trim($v)!="ISO-"&&trim($v)!="EV"&&trim($v)!="mm"&&trim($v)!="s") { $exif_data[$k] = $v
; }
}

if (
$debug
) {
echo
"
"
;
print_r($erdata
);
echo
""
;
}
return
$exif_data
;
}

?>

Share Post:

댓글목록

등록된 댓글이 없습니다.

Sign In
OR
Don't have an account? SIGN UP

Keywords

Visits

접속자

Total Visits
1,893,169