Moar error handling for r53546
[lhc/web/wiklou.git] / includes / media / GIF.php
1 <?php
2 /**
3 * @file
4 * @ingroup Media
5 */
6
7 /**
8 * Handler for GIF images.
9 *
10 * @ingroup Media
11 */
12 class GIFHandler extends BitmapHandler {
13
14 function getMetadata( $image, $filename ) {
15 if ( !isset($image->parsedGIFMetadata) )
16 $image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
17
18 return serialize($image->parsedGIFMetadata);
19
20 }
21
22 function formatMetadata( $image ) {
23 return false;
24 }
25
26 function getImageArea( $image, $width, $height ) {
27 if ($metadata) {
28 $metadata = unserialize($image->getMetadata());
29 return $width * $height * $metadata['frameCount'];
30 } else {
31 return $width * $height;
32 }
33 }
34
35 function getMetadataType( $image ) {
36 return 'parsed-gif';
37 }
38
39 function getLongDesc( $image ) {
40 global $wgUser, $wgLang;
41 $sk = $wgUser->getSkin();
42
43 $metadata = @unserialize($image->getMetadata());
44
45 if (!$metadata) return parent::getLongDesc( $image );
46
47 $info = array();
48 $info[] = $image->getMimeType();
49 $info[] = $sk->formatSize( $image->getSize() );
50
51 if ($metadata['looped'])
52 $info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
53
54 if ($metadata['frameCount'] > 1)
55 $info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
56
57 if ($metadata['duration'])
58 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
59
60 $infoString = $wgLang->commaList( $info );
61
62 return "($infoString)";
63 }
64 }