MediaWiki
master
BmpHandler.php
Go to the documentation of this file.
1
<?php
10
namespace
MediaWiki\Media
;
11
12
use
MediaWiki\FileRepo\File\File
;
13
use
Wikimedia\StringUtils\StringUtils
;
14
use
Wikimedia\UnpackFailedException
;
15
22
class
BmpHandler
extends
BitmapHandler
{
27
public
function
mustRender
( $file ) {
28
return
true
;
29
}
30
39
public
function
getThumbType
( $ext, $mime, $params =
null
) {
40
return
[
'png'
,
'image/png'
];
41
}
42
50
public
function
getSizeAndMetadata
( $state, $filename ) {
51
$f = fopen( $filename,
'rb'
);
52
if
( !$f ) {
53
return
[];
54
}
55
$header = fread( $f, 54 );
56
fclose( $f );
57
58
// Extract binary form of width and height from the header
59
$w = substr( $header, 18, 4 );
60
$h = substr( $header, 22, 4 );
61
62
// Convert the unsigned long 32 bits (little endian):
63
try
{
64
$w = StringUtils::unpack(
'V'
, $w, 4 );
65
$h = StringUtils::unpack(
'V'
, $h, 4 );
66
}
catch
(
UnpackFailedException
) {
67
return
[];
68
}
69
70
return
[
71
'width'
=> $w[1],
72
'height'
=> $h[1]
73
];
74
}
75
}
76
78
class_alias( BmpHandler::class,
'BmpHandler'
);
MediaWiki\FileRepo\File\File
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition
File.php:79
MediaWiki\Media\BitmapHandler
Generic handler for bitmap images.
Definition
BitmapHandler.php:27
MediaWiki\Media\BmpHandler
Handler for Microsoft's bitmap format; getimagesize() doesn't support these files.
Definition
BmpHandler.php:22
MediaWiki\Media\BmpHandler\getThumbType
getThumbType( $ext, $mime, $params=null)
Render files as PNG.
Definition
BmpHandler.php:39
MediaWiki\Media\BmpHandler\getSizeAndMetadata
getSizeAndMetadata( $state, $filename)
Get width and height from the bmp header.
Definition
BmpHandler.php:50
MediaWiki\Media\BmpHandler\mustRender
mustRender( $file)
Definition
BmpHandler.php:27
Wikimedia\StringUtils\StringUtils
A collection of static methods to play with strings.
Definition
StringUtils.php:21
Wikimedia\UnpackFailedException
Definition
UnpackFailedException.php:10
MediaWiki\Media
Definition
BitmapHandler.php:10
includes
Media
BmpHandler.php
Generated on Wed Jan 14 2026 00:25:29 for MediaWiki by
1.10.0