MediaWiki master
BmpHandler.php
Go to the documentation of this file.
1<?php
27
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}
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)
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:93
A collection of static methods to play with strings.