3 * Handler for PNG images.
10 * Handler for PNG images.
14 class PNGHandler
extends BitmapHandler
{
18 * @param string $filename
21 function getMetadata( $image, $filename ) {
22 if ( !isset($image->parsedPNGMetadata
) ) {
24 $image->parsedPNGMetadata
= PNGMetadataExtractor
::getMetadata( $filename );
25 } catch( Exception
$e ) {
27 wfDebug( __METHOD__
. ': ' . $e->getMessage() . "\n" );
32 return serialize($image->parsedPNGMetadata
);
36 function formatMetadata( $image ) {
44 function isAnimatedImage( $image ) {
45 $ser = $image->getMetadata();
47 $metadata = unserialize($ser);
48 if( $metadata['frameCount'] > 1 ) return true;
53 function getMetadataType( $image ) {
57 function isMetadataValid( $image, $metadata ) {
59 $data = unserialize( $metadata );
61 return (boolean
) $data;
68 function getLongDesc( $image ) {
70 $original = parent
::getLongDesc( $image );
73 $metadata = unserialize($image->getMetadata());
76 if( !$metadata ||
$metadata['frameCount'] <= 0 )
82 if ($metadata['loopCount'] == 0)
83 $info[] = wfMsgExt( 'file-info-png-looped', 'parseinline' );
84 elseif ($metadata['loopCount'] > 1)
85 $info[] = wfMsgExt( 'file-info-png-repeat', 'parseinline', $metadata['loopCount'] );
87 if ($metadata['frameCount'] > 0)
88 $info[] = wfMsgExt( 'file-info-png-frames', 'parseinline', $metadata['frameCount'] );
90 if ($metadata['duration'])
91 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
93 return $wgLang->commaList( $info );