MediaWiki
master
BmpHandler.php
Go to the documentation of this file.
1
<?php
24
use
MediaWiki\FileRepo\File\File
;
25
use
MediaWiki\Libs\UnpackFailedException
;
26
use
Wikimedia\StringUtils\StringUtils
;
27
34
class
BmpHandler
extends
BitmapHandler
{
39
public
function
mustRender
( $file ) {
40
return
true
;
41
}
42
51
public
function
getThumbType
( $ext, $mime, $params =
null
) {
52
return
[
'png'
,
'image/png'
];
53
}
54
62
public
function
getSizeAndMetadata
( $state, $filename ) {
63
$f = fopen( $filename,
'rb'
);
64
if
( !$f ) {
65
return
[];
66
}
67
$header = fread( $f, 54 );
68
fclose( $f );
69
70
// Extract binary form of width and height from the header
71
$w = substr( $header, 18, 4 );
72
$h = substr( $header, 22, 4 );
73
74
// Convert the unsigned long 32 bits (little endian):
75
try
{
76
$w = StringUtils::unpack(
'V'
, $w, 4 );
77
$h = StringUtils::unpack(
'V'
, $h, 4 );
78
}
catch
(
UnpackFailedException
$e ) {
79
return
[];
80
}
81
82
return
[
83
'width'
=> $w[1],
84
'height'
=> $h[1]
85
];
86
}
87
}
BitmapHandler
Generic handler for bitmap images.
Definition
BitmapHandler.php:35
BmpHandler
Handler for Microsoft's bitmap format; getimagesize() doesn't support these files.
Definition
BmpHandler.php:34
BmpHandler\getThumbType
getThumbType( $ext, $mime, $params=null)
Render files as PNG.
Definition
BmpHandler.php:51
BmpHandler\getSizeAndMetadata
getSizeAndMetadata( $state, $filename)
Get width and height from the bmp header.
Definition
BmpHandler.php:62
BmpHandler\mustRender
mustRender( $file)
Definition
BmpHandler.php:39
MediaWiki\FileRepo\File\File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition
File.php:93
MediaWiki\Libs\UnpackFailedException
Definition
UnpackFailedException.php:10
Wikimedia\StringUtils\StringUtils
A collection of static methods to play with strings.
Definition
StringUtils.php:35
includes
media
BmpHandler.php
Generated on Wed May 21 2025 12:24:44 for MediaWiki by
1.10.0