26742674246bc3a50f6c4478410b99c8e1693fcb
[lhc/web/wiklou.git] / includes / media / Tiff.php
1 <?php
2 /**
3 * Handler for Tiff images.
4 *
5 * @file
6 * @ingroup Media
7 */
8
9 /**
10 * Handler for Tiff images.
11 *
12 * @ingroup Media
13 */
14 class TiffHandler extends ExifBitmapHandler {
15
16 /**
17 * Conversion to PNG for inline display can be disabled here...
18 * Note scaling should work with ImageMagick, but may not with GD scaling.
19 *
20 * @param $file
21 *
22 * @return bool
23 */
24 function canRender( $file ) {
25 global $wgTiffThumbnailType;
26 return (bool)$wgTiffThumbnailType;
27 }
28
29 /**
30 * Browsers don't support TIFF inline generally...
31 * For inline display, we need to convert to PNG.
32 *
33 * @param $file
34 *
35 * @return bool
36 */
37 function mustRender( $file ) {
38 return true;
39 }
40
41 /**
42 * @param $ext
43 * @param $mime
44 * @param $params
45 * @return bool
46 */
47 function getThumbType( $ext, $mime, $params = null ) {
48 global $wgTiffThumbnailType;
49 return $wgTiffThumbnailType;
50 }
51
52 /**
53 * @param $image
54 * @param $filename
55 * @return string
56 */
57 function getMetadata( $image, $filename ) {
58 global $wgShowEXIF;
59 if ( $wgShowEXIF && file_exists( $filename ) ) {
60 $exif = new Exif( $filename );
61 $data = $exif->getFilteredData();
62 if ( $data ) {
63 $data['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
64 return serialize( $data );
65 } else {
66 return ExifBitmapHandler::BROKEN_FILE;
67 }
68 } else {
69 return '';
70 }
71 }
72 }