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 ) {
41 function getImageArea( $image, $width, $height ) {
42 $ser = $image->getMetadata();
44 $metadata = unserialize($ser);
45 return $width * $height * $metadata['frameCount'];
47 return $width * $height;
55 function isAnimatedImage( $image ) {
56 $ser = $image->getMetadata();
58 $metadata = unserialize($ser);
59 if( $metadata['frameCount'] > 1 ) return true;
64 function getMetadataType( $image ) {
68 function isMetadataValid( $image, $metadata ) {
70 $data = unserialize( $metadata );
72 return (boolean
) $data;
79 function getLongDesc( $image ) {
82 $original = parent
::getLongDesc( $image );
85 $metadata = unserialize($image->getMetadata());
88 if (!$metadata ||
$metadata['frameCount'] <= 1)
91 /* Preserve original image info string, but strip the last char ')' so we can add even more */
95 if ($metadata['looped'])
96 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
98 if ($metadata['frameCount'] > 1)
99 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
101 if ($metadata['duration'])
102 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
104 return $wgLang->commaList( $info );