Class
- Tip&Tech
| [ÇÔ¼ö] »çÁø Ä«·¹¸¶ Á¤º¸ exif Ŭ·¡½º ¼öÁ¤º» | |||||
| ±Û¾´ÀÌ | ³¯ Â¥ | 10-02-07 21:25 | Á¶ ȸ | 3476 | |
|---|---|---|---|---|---|
| °£ÆíURL |
http://www.phpschool.com/link/tipntech/71124
|
||||
| Link1 | http://apmsoftax.mireene.com/test_exif.php (394) | ||||
| Link2 | http://apmsoftax.com (314) | ||||
|
php5¿ë Ŭ·¡½º ¼öÁ¤º»À» ´Ù½Ã ¿Ã¸³´Ï´Ù
´Ù½Ã ¸¸µé°í ³ª´Ï ÁÁ³×¿ä ÁøÀÛ¿¡ ÀÌÄÉ Çß¾î¾ß Çϴµ¥... ±ÍÂ÷´ÏÁòÀ» À̱âÀÚ ¤»¤»¤» <?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()]); } ?> |
|||||
|
|||||
Àüü´ñ±Û¼ö 0
12345678910


