3 * Handler for GIF images.
10 * Handler for GIF images.
14 class GIFHandler
extends BitmapHandler
{
16 function getMetadata( $image, $filename ) {
17 if ( !isset( $image->parsedGIFMetadata
) ) {
19 $image->parsedGIFMetadata
= GIFMetadataExtractor
::getMetadata( $filename );
20 } catch( Exception
$e ) {
22 wfDebug( __METHOD__
. ': ' . $e->getMessage() . "\n" );
27 return serialize( $image->parsedGIFMetadata
);
31 function formatMetadata( $image ) {
35 function getImageArea( $image, $width, $height ) {
36 $ser = $image->getMetadata();
38 $metadata = unserialize($ser);
39 return $width * $height * $metadata['frameCount'];
41 return $width * $height;
45 function isAnimatedImage( $image ) {
46 $ser = $image->getMetadata();
48 $metadata = unserialize($ser);
49 if( $metadata['frameCount'] > 1 ) return true;
54 function getMetadataType( $image ) {
58 function isMetadataValid( $image, $metadata ) {
60 $data = unserialize( $metadata );
62 return (boolean
) $data;
65 function getLongDesc( $image ) {
68 $original = parent
::getLongDesc( $image );
71 $metadata = unserialize($image->getMetadata());
74 if (!$metadata ||
$metadata['frameCount'] <= 1)
78 $info[] = substr( $original, 1, strlen( $original )-2 );
80 if ($metadata['looped'])
81 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
83 if ($metadata['frameCount'] > 1)
84 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
86 if ($metadata['duration'])
87 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
89 $infoString = $wgLang->commaList( $info );
91 return "($infoString)";