ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


»çÁø Ä«·¹¸¶ Á¤º¸ exif Ŭ·¡½º
12³â Àü
<?php
class ImageExif {
    private $picture;
    private $exifargs = array();
    private $setkey_args = array(
        'file'        => array('FileName','FileSize','FileDateTime','MimeType'),
        'computed'    => array('Width','Height','ApertureFNumber','FocusDistance','CCDWidth'),
                        // ³ÐÀÌ,³ôÀÌ,Á¶¸®°³,ÃÔ¿µ°Å¸®,CCD
        'ifdo'        => array('Make','Model','Software'),
        'exif'        => array('ExposureTime','FNumber','Flash','WhiteBalance','DigitalZoomRatio','ISOSpeedRatings','FocalLength','MeteringMode','DateTimeOriginal'),
                        // ³ëÃâ¸ðµå,Á¶¸®°³°ª,Ç÷¡½Ã»ç¿ë¿©ºÎ,È­ÀÌÆ®¹ß¶õ½º,ÁÜ,ISO°¨µµ,ÃÊÁ¡°Å¸®,Ãø±¤¸ðµå ,¿À¸®Áö³¯ÃÔ¿µ½Ã°£
        'makenote'    => array('FirmwareVersion','UndefinedTag:0x0095')
                        // Æß¿þ¾î¹öÀü,»ç¿ë·»Áî
    );
    
    # »çÁø Ç®°æ·Î
    public function __construct($picture){
        # ·ÎÄà ÆÄÀÎÀÎÁö üũ
        if(!file_exists($picture))
            throw new ErrorReporter('',30);

        # ÇÔ¼ö enable üũ
        if(function_exists(read_exif_data)){
            $this->exifargs = read_exif_data($picture,0,true);
            if($this->exifargs ===false)
                throw new ErrorReporter('');
        }
    }
    
    # ÆÄÀÏ °è»ê
    public function calcuSize($size)
    {
        $result = '';
        if(!empty($size)){
            $result = sprintf("%0.1f KB", ($size/1024));
            if($r>1024){
                $result = sprintf("%0.1f MB", ($r/1024)); //¼öÁ¡ ÀÌÇÏ°¡ 0.5 ´Â 1·Î ¹Ý¿Ã¸²ÇÑ´Ù.
            }
        }
    return $result;
    }
    
    # FILE
    public function getFile()
    {
        $result = array();
        if($this->exifargs['FILE']){
            $args =& $this->exifargs['FILE'];
            foreach($this->setkey_args['file'] as $k){
                switch($k){
                    case 'FileDateTime': $result[$k] = date("Y³â m¿ù dÀÏ H:i:s",$args[$k]); break;
                    case 'FileSize' : $result[$k] = self::calcuSize($args[$k]); break;
                    default : $result[$k]= $args[$k];
                }
            }
        }
    return $result;
    }
    
    # COMPUTED
    public function getComputed()
    {
        $result = array();
        if($this->exifargs['COMPUTED']){
            $args =& $this->exifargs['COMPUTED'];
            foreach($this->setkey_args['computed'] as $k){
                switch($k){
                    case 'FocusDistance':
                        $result[$k] = $args[$k];
                        if(strpos($args[$k],'/') !==false){
                            $tmpdistance = explode('/',$args[$k]);
                            $result[$k] = ($tmpdistance[0]/$tmpdistance[1]).'mm';
                        }
                        break;
                    case 'CCDWidth':
                        $result[$k] = (!empty($args[$k])) ? substr($args[$k],0,5).' mm' : '';
                        break;
                    default :
                        $result[$k] = $args[$k];
                }
            }
        }
    return $result;
    }
    
    # IFDO
    public function getIfdo()
    {
        $result = array();
        if($this->exifargs['IFD0']){
            $args =& $this->exifargs['IFD0'];
            foreach($this->setkey_args['ifdo'] as $k){
                switch($k){
                    case 'Make':
                        $result[$k] = str_replace('CORPORATION','',$args[$k]);
                        break;
                    default:
                        $result[$k] = $args[$k];    
                }
            }
        }
    return $result;
    }
    
    # EXIF
    public function getExif()
    {
        $result = array();
        if($this->exifargs['EXIF']){
            $args =& $this->exifargs['EXIF'];
            foreach($this->setkey_args['exif'] as $k){
                switch($k){
                    case 'Flash': $result[$k] = ($args[$k]==1) ? 'ON' : 'OFF'; break;
                    case 'ExposureTime':
                        $result[$k] = $args[$k];
                        if(strpos($args[$k],'/') !==false){
                            $tmpexpo = explode('/',$args[$k]);
                            $result[$k] = ($tmpexpo[0]/$tmpexpo[0]).'/'.($tmpexpo[1]/$tmpexpo[0]).'s';
                        }
                        break;
                    case 'FocalLength':
                        $result[$k] = $args[$k];
                        if(strpos($args[$k],'/') !==false){
                            $tmpfocal    = explode('/',$args[$k]);
                            $result[$k] = ($tmpfocal[0]/$tmpfocal[1]).'mm';
                        }
                        break;
                    default: $result[$k] = $args[$k];
                }
            }
        }
    return $result;
    }
    
    # MAKENOTE
    public function getMakenote()
    {
        $result = array();
        if($this->exifargs['MAKENOTE']){
            $args =& $this->exifargs['MAKENOTE'];
            foreach($this->setkey_args['makenote'] as $k){
                $result[$k] = $args[$k];
            }
        }
    return $result;
    }
    
    # °ªÀÌ ÀÖ´Â °Íµé¸¸ Çѹø¿¡ ÃßÃâÇϱâ
    public function getAvailable(){
        $args = array();
        if(count($this->exifargs)){
            foreach($this->setkey_args as $k => $v){
                $methodName = 'get'.ucwords($k);
                $args += call_user_func_array(array(&$this, $methodName), array());
            }
        }
    return $args;
    }
}
?>



À§¿¡ ÀÖ´Â exif Ŭ·¡½º¸¦ »ó¼Ó¹Þ¾Æ
ºäŬ·¡½º¸¦ ¸¸µé¾î »ç¿ëÇϸé ÁÁ½À´Ï´Ù.

ºä Ŭ·¡½º¿¡¼­ ÆÄÀÏű׿¡ ´ëÇÑ Çѱ۸í ÀÚµ¿Ãâ·ÂÀ» ¼³Á¤ÇÏ¸é ´õ ÆíÇÏ°ÚÁÒ...

ÀÏ´Ü À§ Ŭ·¡½º Å×½ºÆ®

<?php
$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path.'/config/config.php';

try{
    $out->outPrintln("<img src='./testdirectory/P100119003.jpg'>");
    $exif = new ImageExif($path.'/testdirectory/P100119003.jpg');
    $args = $exif->getAvailable();
    if(is_array($args)){
        foreach($args as $k =>$v){
            if(!empty($v)){
                $out->outPrintln($k.' : '.$v);
            }
        }
    }
    
    $out->outPrintln("----------------------------");
    
    $out->outPrintln("<img src='./testdirectory/DSC_0369.JPG'>");
    $exif2 = new ImageExif($path.'/testdirectory/DSC_0369.JPG');
    $args2 = $exif2->getAvailable();
    if(is_array($args2)){
        foreach($args2 as $k2 =>$v2){
            if(!empty($v2)){
                $out->outPrintln($k2.' : '.$v2);
            }
        }
    }
}
catch(ErrorReporter $e){
    $out->outPrintln($e->getTraceText());
    $out->outPrintln($e->getMessage());
    if( $e->getCode() ) $out->outPrint($error_msg[$e->getCode()]);
}
?>
ÃßõÃßõ : 546 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
215
ÀÏÁ¤½Ã°£ ÀÌ Áö³­ °Ô½Ã¹° Á¤¸®Çϱâ
214
RSS¸¦ ÀÌ¿ëÇÑ ÃֱٰԽù° »Ì±â
213
°£´ÜÇÑ ±ÝÁö´Ü¾î ÇÊÅ͸µ
212
ÁÖ¿ä»çÀÌÆ®µéÀÇ ¸µÅ©Àα⵵ ¸¦ °¡Á®¿Í¼­ º¸¿©ÁÖ±â
211
ÆÄÀÏ À̸§¿¡¼­ È®ÀåÀÚ ÃßÃâ
210
http://ȨÁÖ¼Ò/?mode=xxx Çϴ¹æ¹ý
209
»çÀÌÆ® ¹æ¹®°æ·Î¿Í °Ë»öÇÑ ´Ü¾î ¾Ë±â
208
ÆäÀÌ¡- ´ÙÁß Á¤·Ä : ¿À¸§, ³»¸², º¸Åë
207
ÇöÀç µð·ºÅ丮(Æú´õ) ÆÄÀÏ ¸ñ·Ï º¸±â, PHP¼Ò½º
206
MySQL¿¡ ÀÖ´Â ·¹Äڵ带 php¸¦ »ç¿ëÇؼ­ XML·Î º¯È¯Çϱâ
205
±Ý¾×À» Çѱ۷Πǥ±â ÇØÁÖ´Â ½ºÅ©¸³Æ®
204
ȨÆäÀÌÁö µ¿½ÃÁ¢¼ÓÀÚ¼ö ±¸ÇöÀ» À§ÇÑ PHP ¼Ò½º ÄÚµå
203
¿©·¯ °Ô½ÃÆÇÀÇ °ªµéÀ» °¡Á®¿Í¼­ Á¤·ÄÇϱâ
202
Áֹεî·Ï¹øÈ£°¡ Æ÷ÇÔµÇ¸é °æ°í
201
¾ÆÀ̵𿡠ÇÑ±Û ¹× Ư¼ö¹®ÀÚ Á¦ÇÑ ½±°Ô
200
´ë·® ¸ÞÀÏ ¹ß¼Û ¼Ò½º
199
±âº»ÀûÀÎ ÆäÀÌ¡
»çÁø Ä«·¹¸¶ Á¤º¸ exif Ŭ·¡½º
197
display:inlineÀÇ À߸øµÈ ¿ÀÇØ
196
[jQuery] $(document).ready(function(){});
195
phpquery
194
IE6ºÎÅÍ IE9±îÁö ´ëÀÀÇϱâ.
193
HTML ű׸¦ ¸·±â
192
jquery ajax, $.get(), $.post() »ç¿ë¹æ¹ý
191
jquery form - ajaxForm
190
jquery ÃֽŠ¹öÀü ¿¬°áÇϱâ
189
¸ð¹ÙÀÏÀ¥À¸·Î Æ÷¿öµùÇÏ´Â ½ºÅ©¸³Æ®
188
JQuery ±âº» ¿¹Á¦ ¸ðÀ½
187
¸®´ª½º ƯÁ¤ ¹®ÀÚ¿­ ã±â
186
grep perl Á¶ÇÕÀ¸·Î ÆÄÀϳ» ¹®ÀÚ¿­À» ÇѲ¨¹ø¿¡ º¯°æÇϱâ
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.