blob: c4ede33103a08202867b61d62c110aab111e3803 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
<?php
/**
* Handler for GIF images.
*
* @file
* @ingroup Media
*/
/**
* Handler for GIF images.
*
* @ingroup Media
*/
class GIFHandler extends BitmapHandler {
function getMetadata( $image, $filename ) {
if ( !isset( $image->parsedGIFMetadata ) ) {
try {
$image->parsedGIFMetadata = GIFMetadataExtractor::getMetadata( $filename );
} catch( Exception $e ) {
// Broken file?
wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
return '0';
}
}
return serialize( $image->parsedGIFMetadata );
}
function formatMetadata( $image ) {
return false;
}
function getImageArea( $image, $width, $height ) {
$ser = $image->getMetadata();
if ($ser) {
$metadata = unserialize($ser);
return $width * $height * $metadata['frameCount'];
} else {
return $width * $height;
}
}
function isAnimatedImage( $image ) {
$ser = $image->getMetadata();
if ($ser) {
$metadata = unserialize($ser);
if( $metadata['frameCount'] > 1 ) return true;
}
return false;
}
function getMetadataType( $image ) {
return 'parsed-gif';
}
function isMetadataValid( $image, $metadata ) {
wfSuppressWarnings();
$data = unserialize( $metadata );
wfRestoreWarnings();
return (boolean) $data;
}
function getLongDesc( $image ) {
global $wgLang;
$original = parent::getLongDesc( $image );
wfSuppressWarnings();
$metadata = unserialize($image->getMetadata());
wfRestoreWarnings();
if (!$metadata || $metadata['frameCount'] <= 1)
return $original;
$info = array();
$info[] = $original;
if ($metadata['looped'])
$info[] = wfMsgExt( 'file-info-gif-looped', 'parseinline' );
if ($metadata['frameCount'] > 1)
$info[] = wfMsgExt( 'file-info-gif-frames', 'parseinline', $metadata['frameCount'] );
if ($metadata['duration'])
$info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
return $wgLang->commaList( $info );
}
}
|