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 ) {
57 $data = @unserialize
( $metadata );
58 return (boolean
) $data;
61 function getLongDesc( $image ) {
62 global $wgUser, $wgLang;
63 $sk = $wgUser->getSkin();
65 $metadata = @unserialize
($image->getMetadata());
67 if (!$metadata) return parent
::getLongDesc( $image );
70 $info[] = $image->getMimeType();
71 $info[] = $sk->formatSize( $image->getSize() );
73 if ($metadata['looped'])
74 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
76 if ($metadata['frameCount'] > 1)
77 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
79 if ($metadata['duration'])
80 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
82 $infoString = $wgLang->commaList( $info );
84 return "($infoString)";