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


»çÁø Ä«·¹¸¶ Á¤º¸ 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()]);
}
?>
ÃßõÃßõ : 549 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
2,165
php ³»Àå ¸¸³â´Þ·Â
2,164
php ÀÚÁÖ¾²ÀÌ´Â ÇÔ¼ö
2,163
PHP Äڵ带 ÃÖÀûÈ­ÇÏ´Â 40°¡Áö ÆÁ (¹ø¿ª)
2,162
Áֹεî·Ï¹øÈ£°¡ Æ÷ÇÔµÇ¸é °æ°í
2,161
³¯Â¥ºñ±³ ÇÔ¼ö
2,160
À¯¿ëÇÑ PHP ȯ°æº¯¼ö
2,159
ÇÁ·¹ÀÓÀ¸·Î ³ª´²Áø ÆäÀÌÁö¿¡¼­ »õ·Î°íħ½Ã ÇöÀç ÆäÀÌÁö À¯ÁöÇϱâ
2,158
SelectBox Ŭ·¡½ºÀÔ´Ï´Ù
2,157
¾ÆÀ̵𿡠ÇÑ±Û ¹× Ư¼ö¹®ÀÚ Á¦ÇÑ ½±°Ô
2,156
»çÀÌÆ® ȯ°æ¼³Á¤ÀÇ ¹æ¹ý
2,155
´ë·® ¸ÞÀÏ ¹ß¼Û ¼Ò½º
2,154
±âº»ÀûÀÎ ÆäÀÌ¡
2,153
$_SERVER[DOCUMENT_ROOT]ÀÇ Ç¥Çö¹æ¹ý
2,152
$PHP_SELF °¡ ¾ÈµÉ¶§
2,151
À̹ø´Þ Àϼö ±¸Çϱâ
2,150
°ü¸®ÀÚ ¹× ȸ¿øÀÇ ÆäÀÌÁö Á¢±Ù ±ÇÇÑ °£´Ü±¸Çö
2,149
iframe resize ÇÔ¼ö
»çÁø Ä«·¹¸¶ Á¤º¸ exif Ŭ·¡½º
2,147
PHP°´Ã¼ÁöÇâ ÇÁ·Î±×·¡¹Ö
2,146
PHP Ŭ·¡½º »ç¿ë
2,145
PHP·Î ±¸ÇöÇÑ °Ô½ÃÆÇ ÀÚµ¿ µî·Ï±â Ŭ·¡½º
2,144
MD5¸¦ ÀÌ¿ëÇÑ ¾Ïȣȭ/º¹È£È­
2,143
´Þ·Â, ¿ù~ÀÏ(ÀÏ~¿ù) ±¸°£, ¿äÀϼö µî Á¾ÇÕ
2,142
À¯¿ëÇÑ ÇÔ¼ö ¸ðÀ½
2,141
PHP ¼¼¼Ç ´Ù·ç±â
2,140
°èÁ¤ ¿ë·® È®ÀÎÇÏ´Â PHP
2,139
PHP °¢Á¾ ¿À·ù Á¤¸®
2,138
x ÃÊÈÄ ³ªÅ¸³ª´Â ·¹À̾î...
2,137
display:inlineÀÇ À߸øµÈ ¿ÀÇØ
2,136
meta È­¸éÀÌÆåÆ®
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.