讀取JPEG圖檔dpi
function get_dpi($filename){
   // open the file and read first 20 bytes.
   $a = fopen($filename,'r');
   $string = fread($a,20);
   fclose($a);
   // get the value of byte 14th up to 18th
   $data = bin2hex(substr($string,14,4));
   $x = substr($data,0,4);
   $y = substr($data,4,4);  
   /* $x,$y: 01 2C = 300dpi ; 00 48 = 72dpi  */
   return array(hexdec($x),hexdec($y));
}
程式出處: http://sandalian.com/php/get-dpi-value-of-an-image-using-php.html
JPEG結構說明: http://bytes.com/groups/php/5948-dpi-php-gd
JPEG結構&DPI說明: http://apptools.com/examples/dpi.php
 
沒有留言:
張貼留言