8 * Handler for GIF images.
12 class GIFHandler
extends BitmapHandler
{
14 function getMetadata( $image, $filename ) {
15 if ( !isset($image->parsedGIFMetadata
) ) {
17 $image->parsedGIFMetadata
= GIFMetadataExtractor
::getMetadata( $filename );
18 } catch( Exception
$e ) {
20 wfDebug( __METHOD__
. ': ' . $e->getMessage() . "\n" );
25 return serialize($image->parsedGIFMetadata
);
29 function formatMetadata( $image ) {
33 function getImageArea( $image, $width, $height ) {
34 $ser = $image->getMetadata();
36 $metadata = unserialize($ser);
37 return $width * $height * $metadata['frameCount'];
39 return $width * $height;
43 function isAnimatedImage( $image ) {
44 $ser = $image->getMetadata();
46 $metadata = unserialize($ser);
47 if( $metadata['frameCount'] > 1 ) return true;
52 function getMetadataType( $image ) {
56 function isMetadataValid( $image, $metadata ) {
58 $data = unserialize( $metadata );
60 return (boolean
) $data;
63 function getLongDesc( $image ) {
64 global $wgUser, $wgLang;
65 $sk = $wgUser->getSkin();
66 $original = parent
::getLongDesc( $image );
69 $metadata = unserialize($image->getMetadata());
72 if (!$metadata ||
$metadata['frameCount'] <= 1)
76 $info[] = substr( $original, 1, strlen( $original )-2 );
78 if ($metadata['looped'])
79 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
81 if ($metadata['frameCount'] > 1)
82 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
84 if ($metadata['duration'])
85 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
87 $infoString = $wgLang->commaList( $info );
89 return "($infoString)";