New hook getOtherBlockLogLink, called in Special:IPBlockList to show links to block...
[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 // We never want to use .bmp in an <img/> tag
15 function mustRender( $file ) {
16 return true;
17 }
18
19 // Render files as PNG
20 function getThumbType( $text, $mime ) {
21 return array( 'png', 'image/png' );
22 }
23
24 /*
25 * Get width and height from the bmp header.
26 */
27 function getImageSize( $image, $filename ) {
28 $f = fopen( $filename, 'r' );
29 if(!$f) return false;
30 $header = fread( $f, 54 );
31 fclose($f);
32
33 // Extract binary form of width and height from the header
34 $w = substr( $header, 18, 4);
35 $h = substr( $header, 22, 4);
36
37 // Convert the unsigned long 32 bits (little endian):
38 $w = unpack( 'V' , $w );
39 $h = unpack( 'V' , $h );
40 return array( $w[1], $h[1] );
41 }
42 }