사진의 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 "<pre>";
print_r($erdata);
echo "</pre>";
}
return $exif_data;
}
?>
출처 : http://goosemong.egloos.com/4876641
/***************************************************************************
# 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 "<pre>";
print_r($erdata);
echo "</pre>";
}
return $exif_data;
}
?>
출처 : http://goosemong.egloos.com/4876641
- 이전글php 환경변수정리 21.02.09
- 다음글썸네일시 바탕(배경)이미지 넣기 (water mark) 21.02.09
댓글목록
등록된 댓글이 없습니다.