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
);
30 function formatMetadata( $image ) {
40 function getImageArea( $image, $width, $height ) {
41 $ser = $image->getMetadata();
43 $metadata = unserialize($ser);
44 return $width * $height * $metadata['frameCount'];
46 return $width * $height;
54 function isAnimatedImage( $image ) {
55 $ser = $image->getMetadata();
57 $metadata = unserialize($ser);
58 if( $metadata['frameCount'] > 1 ) {
65 function getMetadataType( $image ) {
69 function isMetadataValid( $image, $metadata ) {
71 $data = unserialize( $metadata );
73 return (boolean
) $data;
80 function getLongDesc( $image ) {
83 $original = parent
::getLongDesc( $image );
86 $metadata = unserialize($image->getMetadata());
89 if (!$metadata ||
$metadata['frameCount'] <= 1) {
93 /* Preserve original image info string, but strip the last char ')' so we can add even more */
97 if ( $metadata['looped'] ) {
98 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
101 if ( $metadata['frameCount'] > 1 ) {
102 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
105 if ( $metadata['duration'] ) {
106 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
109 return $wgLang->commaList( $info );