MediaWiki master
BmpHandler.php
Go to the documentation of this file.
1<?php
25
37 public function mustRender( $file ) {
38 return true;
39 }
40
49 public function getThumbType( $ext, $mime, $params = null ) {
50 return [ 'png', 'image/png' ];
51 }
52
60 public function getSizeAndMetadata( $state, $filename ) {
61 $f = fopen( $filename, 'rb' );
62 if ( !$f ) {
63 return [];
64 }
65 $header = fread( $f, 54 );
66 fclose( $f );
67
68 // Extract binary form of width and height from the header
69 $w = substr( $header, 18, 4 );
70 $h = substr( $header, 22, 4 );
71
72 // Convert the unsigned long 32 bits (little endian):
73 try {
74 $w = StringUtils::unpack( 'V', $w, 4 );
75 $h = StringUtils::unpack( 'V', $h, 4 );
76 } catch ( UnpackFailedException $e ) {
77 return [];
78 }
79
80 return [
81 'width' => $w[1],
82 'height' => $h[1]
83 ];
84 }
85}
array $params
The job parameters.
Generic handler for bitmap images.
Handler for Microsoft's bitmap format; getimagesize() doesn't support these files.
getThumbType( $ext, $mime, $params=null)
Render files as PNG.
getSizeAndMetadata( $state, $filename)
Get width and height from the bmp header.
mustRender( $file)
$header