(bug 35565) Special:Log/patrol doesn't indicate whether patrolling was automatic
[mediawiki.git] / includes / media / Tiff.php
blob0f317e1a8d9cb69a08941d347db1e7a54cbd9bcd
1 <?php
2 /**
3 * Handler for Tiff images.
5 * @file
6 * @ingroup Media
7 */
9 /**
10 * Handler for Tiff images.
12 * @ingroup Media
14 class TiffHandler extends ExifBitmapHandler {
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.
20 * Files pulled from an another MediaWiki instance via ForeignAPIRepo /
21 * InstantCommons will have thumbnails managed from the remote instance,
22 * so we can skip this check.
24 * @param $file
26 * @return bool
28 function canRender( $file ) {
29 global $wgTiffThumbnailType;
30 return (bool)$wgTiffThumbnailType
31 || ($file->getRepo() instanceof ForeignAPIRepo);
34 /**
35 * Browsers don't support TIFF inline generally...
36 * For inline display, we need to convert to PNG.
38 * @param $file
40 * @return bool
42 function mustRender( $file ) {
43 return true;
46 /**
47 * @param $ext
48 * @param $mime
49 * @param $params
50 * @return bool
52 function getThumbType( $ext, $mime, $params = null ) {
53 global $wgTiffThumbnailType;
54 return $wgTiffThumbnailType;
57 /**
58 * @param $image
59 * @param $filename
60 * @return string
62 function getMetadata( $image, $filename ) {
63 global $wgShowEXIF;
64 if ( $wgShowEXIF ) {
65 try {
66 $meta = BitmapMetadataHandler::Tiff( $filename );
67 if ( !is_array( $meta ) ) {
68 // This should never happen, but doesn't hurt to be paranoid.
69 throw new MWException('Metadata array is not an array');
71 $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
72 return serialize( $meta );
74 catch ( MWException $e ) {
75 // BitmapMetadataHandler throws an exception in certain exceptional
76 // cases like if file does not exist.
77 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
78 return ExifBitmapHandler::BROKEN_FILE;
80 } else {
81 return '';