MediaWiki  REL1_24
Tiff.php
Go to the documentation of this file.
00001 <?php
00029 class TiffHandler extends ExifBitmapHandler {
00030     const EXPENSIVE_SIZE_LIMIT = 10485760; // TIFF files over 10M are considered expensive to thumbnail
00031 
00043     function canRender( $file ) {
00044         global $wgTiffThumbnailType;
00045 
00046         return (bool)$wgTiffThumbnailType
00047             || $file->getRepo() instanceof ForeignAPIRepo;
00048     }
00049 
00057     function mustRender( $file ) {
00058         return true;
00059     }
00060 
00067     function getThumbType( $ext, $mime, $params = null ) {
00068         global $wgTiffThumbnailType;
00069 
00070         return $wgTiffThumbnailType;
00071     }
00072 
00079     function getMetadata( $image, $filename ) {
00080         global $wgShowEXIF;
00081         if ( $wgShowEXIF ) {
00082             try {
00083                 $meta = BitmapMetadataHandler::Tiff( $filename );
00084                 if ( !is_array( $meta ) ) {
00085                     // This should never happen, but doesn't hurt to be paranoid.
00086                     throw new MWException( 'Metadata array is not an array' );
00087                 }
00088                 $meta['MEDIAWIKI_EXIF_VERSION'] = Exif::version();
00089 
00090                 return serialize( $meta );
00091             } catch ( MWException $e ) {
00092                 // BitmapMetadataHandler throws an exception in certain exceptional
00093                 // cases like if file does not exist.
00094                 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
00095 
00096                 return ExifBitmapHandler::BROKEN_FILE;
00097             }
00098         } else {
00099             return '';
00100         }
00101     }
00102 
00103     public function isExpensiveToThumbnail( $file ) {
00104         return $file->getSize() > static::EXPENSIVE_SIZE_LIMIT;
00105     }
00106 }