사이트 내 전체검색
PHP
[php] 사진 정보(Exif) 표시
로빈아빠
https://cmd.kr/php/538 URL이 복사되었습니다.

본문

사진 정보(Exif) 표시

응용하세요
//****************************************************
//  만든이 : 엔젤퀸 http://ngelqueen.cafe24.com  ngelqueen@naver.com 
//****************************************************

    function info($var,$hide,$former,$latter){ 
        /************************** 
        info 함수 : $var 가 존재하고, $hide 값이 아닐 때에, 앞 쪽에 $former, 뒤 쪽에 $latter를 붙여서 리턴한다. 
        예 : info($exposuretime,$x,$x,"s"); ==> $exposuretime 변수가 $x 값이 아니므로, 앞 쪽에 $x, 뒤쪽에 s를 붙여 리턴한다. ($x는 !$isset) ==>결과 예 : 1/1200s 
        **************************/ 
        if(isset($var)){ 
            if(!$hide){ 
                $var=$former.$var.$latter; 
                return $var; 
            }else{ 
                if($var!=$hide){ 
                    $var=$former.$var.$latter; 
                    return $var; 
                } 
            } 
        } 
    } 

    function get_picture_info($spath,$cval){ 
        $file="./".$spath.$cval[1]; 
        $info=@exif_read_data($file); 
        if($info[Make]&&$info[Model]&&$info[COMPUTED][ApertureFNumber]&&$info[ExposureTime]){ 
            /************************** 
            변수 설명 
                $datetimeoriginal : 촬영 날짜 
                $fnumber : F수 
                $company : 제조 회사 ex)NIKON, NIKON CORPORATION 
                $model : 모델명 ex)E3200(COOLPIX3200은 E3200으로 나옵니다.), D70 
                $exposuretime : 노출 시간 
                $iso : ISO 
                $focallength : 초점 거리 
                $focallengthin35mmfilm : 35mm 필름 환산시 초점 거리 
                $lightsource : 광원 
                $exposureprogram : 노출 방식 (M, A, S, P) 
                $meteringmode : 측광 방식 ex) 스팟 측광, 패턴 측광 
                $exposuremode : 노출 방식 ex)자동, 수동, 브라켓 
                $exposurebiasvalue : EV 스텝 ex)3.0 EV 
                $whitebalance : 화이트 밸런스 
            **************************/ 
            $filedatetime=$info[FileDateTime];// => 1116461820 //TIMESTAMP 
            $date=date("Y년 n월 j일 A g시 i분 s초",$filedatetime); 
            $datetimeoriginal=$info[DateTimeOriginal];// => 2005:05:19 09:17:00 
            $datetimedigitized=$info[DateTimeDigitized];// => 2005:05:19 09:17:00 
            $fnumber=$info[COMPUTED][ApertureFNumber];//F수 
            $company=$info[Make];//제조회사 ex)NIKON 
            $model=$info[Model];//모델명 ex)E3200 
            $exposuretime=$info[ExposureTime];//노출시간 ex)10/3000 
            if(gettype($exposuretime)=="string"){ 
                if(ereg("/",$exposuretime)){ 
                    $exposuretime_array=explode("/",$exposuretime); 
                    if($exposuretime_array[0]!=$exposuretime_array[1]){ 
                        for($i=0;($i<=$exposuretime_array[0])&&($i<=$exposuretime_array[1]);$i++){ 
                            if(($exposuretime_array[0]%$i==0)&&($exposuretime_array[1]%$i==0)){ 
                                $gcm=$i; 
                            } 
                        } 
                        $exposuretime_array[0]/=$gcm; 
                        $exposuretime_array[1]/=$gcm; 
                        $exposuretime=$exposuretime_array[0]."/".$exposuretime_array[1]; 
                    }else{ 
                        $exposuretime=1; 
                    } 
                } 
            } 
            $iso=$info[ISOSpeedRatings]; 
            $focallength=$info[FocalLength];//초점거리 ex)174/10 
            if(gettype($focallength)=="string"){ 
                if(ereg("/",$focallength)){ 
                    $focallength_array=explode("/",$focallength); 
                    if($focallength_array[1]%10==0){ 
                        if($focallength_array[0]%10==0){ 
                            $focallength=($focallength_array[0]/10)."/".($focallength_array[1]/10); 
                        }else{ 
                            $focallength=$focallength_array[0]/$focallength_array[1]; 
                        } 
                    }else if($focallength_array[1]==1){ 
                        $focallength=$focallength_array[0]; 
                    } 
                } 
            } 
            $focallengthin35mmfilm=$info[FocalLengthIn35mmFilm];//35mm필름 환산시 초점거리 => 115 
            $lightsource=$info[LightSource];//광원 => 0 
            $lightsource_array=Array('0' => 'unknown','1' => 'Daylight','2' => 'Fluorescent','3' => 'Tungsten (incandescent light)','4' => 'Flash','9' => 'Fine weather','10' => 'Cloudy weather','11' => 'Shade','12' =>'Daylight fluorescent (D 5700 . 7100K)','13' => 'Day white fluorescent (N 4600 . 5400K)','14' => 'Cool white fluorescent (W 3900 . 4500K)','15' => 'White fluorescent (WW 3200 . 3700K)','17' => 'Standard light A','18' => 'Standard light B','19' => 'Standard light C','20' => 'D55','21' => 'D65','22' => 'D75','23' => 'D50','24' => 'ISO studio tungsten','255' => 'other light source'); 
            $lightsource=$lightsource_array[$lightsource]; 
            $exposureprogram=$info[ExposureProgram];//노출방식(M,A,S,P) ex)2 
            $exposureprogram_array=Array('0' => 'Not defined','1' => 'Manual','2' => 'Normal program','3' => 'Aperture priority','4' => 'Shutter priority','5' => 'Creative program (biased toward depth of field)','6' => 'Action program (biased toward fast shutter speed)','7' => 'Portrait mode (for closeup photos with the background out of focus)','8' => 'Landscape mode (for landscape photos with the background in focus)'); 
            $exposureprogram=$exposureprogram_array[$exposureprogram]; 
            $meteringmode=$info[MeteringMode];//측광방식 => 5 
            $meteringmode_array=Array('0' => 'unknown','1' => 'Average','2' => 'CenterWeightedAverage','3' => 'Spot','4' => 'MultiSpot','5' => 'Pattern','6' => 'Partial','255' => 'other'); 
            $meteringmode=$meteringmode_array[$meteringmode]; 
            $exposuremode=$info[ExposureMode];//노출방식 => 0 
            $exposuremode_array=Array('0'=>'Auto exposure','1'=>'Manual exposure','2'=>'Auto bracket'); 
            $exposuremode=$exposuremode_array[$exposuremode]; 
            $exposurebiasvalue=$info[ExposureBiasValue];// => 0/10 
            if(gettype($exposurebiasvalue)=="string"){ 
                if(ereg("/",$exposurebiasvalue)){ 
                    $exposurebiasvalue_array=explode("/",$exposurebiasvalue); 
                    $exposurebiasvalue=$exposurebiasvalue_array[0]/$exposurebiasvalue_array[1]; 
                    $exposurebiasvalue*=10; 
                    $exposurebiasvalue=floor($exposurebiasvalue); 
                    $exposurebiasvalue/=10; 
                    if(gettype($exposurebiasvalue)=="integer"){ 
                        $exposurebiasvalue.=".0"; 
                    } 
                } 
            } 
            $whitebalance=$info[WhiteBalance];// => 0 
            if($whitebalance==0){ 
                $whitebalance="Auto white balance"; 
            }else{ 
                $whitebalance="Manual white balance"; 
            } 
            //$string=info($company,$x,$x,$x); 
            $string=info($company,$x,$x,$x).info($model,$x," ",$x).info($datetimeoriginal,$x," - ",$x); 
            $string.="<br>".info($fnumber,$x,$x,$x).info($focallengthin35mmfilm,$x," ","mm").info($iso,$x," ISO",$x).info($exposuretime,$x," ","s"); 
            //$string.="<br>".info($focallength,$x,$x,"mm").info($focallengthin35mmfilm,$x,"(35mm film : ","mm)"); 
            return $string; 
        } 
    } 

?>

댓글목록

등록된 댓글이 없습니다.

PHP
871 (9/18P)

Search

Copyright © Cmd 명령어 3.145.68.167