WARNING: HUGE COMMIT
[lhc/web/wiklou.git] / includes / media / BMP.php
1 <?php
2 /**
3 * @file
4 * @ingroup Media
5 */
6
7 /**
8 * Handler for Microsoft's bitmap format; getimagesize() doesn't
9 * support these files
10 *
11 * @ingroup Media
12 */
13 class BmpHandler extends BitmapHandler {
14
15 /*
16 * Get width and height from the bmp header.
17 */
18 function getImageSize( $image, $filename ) {
19 $f = fopen( $filename, 'r' );
20 if(!$f) return false;
21 $header = fread( $f, 54 );
22 fclose($f);
23
24 // Extract binary form of width and height from the header
25 $w = substr( $header, 18, 4);
26 $h = substr( $header, 22, 4);
27
28 // Convert the unsigned long 32 bits (little endian):
29 $w = unpack( 'V' , $w );
30 $h = unpack( 'V' , $h );
31 return array( $w[1], $h[1] );
32 }
33 }