00001 <?php
00012 class GIFHandler extends BitmapHandler {
00013
00014 function getMetadata( $image, $filename ) {
00015 if ( !isset($image->parsedGIFMetadata) ) {
00016 try {
00017 $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
00018 } catch( Exception $e ) {
00019
00020 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
00021 return '0';
00022 }
00023 }
00024
00025 return serialize($image->parsedGIFMetadata);
00026
00027 }
00028
00029 function formatMetadata( $image ) {
00030 return false;
00031 }
00032
00033 function getImageArea( $image, $width, $height ) {
00034 $ser = $image->getMetadata();
00035 if ($ser) {
00036 $metadata = unserialize($ser);
00037 return $width * $height * $metadata['frameCount'];
00038 } else {
00039 return $width * $height;
00040 }
00041 }
00042
00043 function getMetadataType( $image ) {
00044 return 'parsed-gif';
00045 }
00046
00047 function getLongDesc( $image ) {
00048 global $wgUser, $wgLang;
00049 $sk = $wgUser->getSkin();
00050
00051 $metadata = @unserialize($image->getMetadata());
00052
00053 if (!$metadata) return parent::getLongDesc( $image );
00054
00055 $info = array();
00056 $info[] = $image->getMimeType();
00057 $info[] = $sk->formatSize( $image->getSize() );
00058
00059 if ($metadata['looped'])
00060 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
00061
00062 if ($metadata['frameCount'] > 1)
00063 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
00064
00065 if ($metadata['duration'])
00066 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
00067
00068 $infoString = $wgLang->commaList( $info );
00069
00070 return "($infoString)";
00071 }
00072 }