3 * Handler for PNG images.
10 * Handler for PNG images.
14 class PNGHandler
extends BitmapHandler
{
16 function getMetadata( $image, $filename ) {
17 if ( !isset($image->parsedPNGMetadata
) ) {
19 $image->parsedPNGMetadata
= PNGMetadataExtractor
::getMetadata( $filename );
20 } catch( Exception
$e ) {
22 wfDebug( __METHOD__
. ': ' . $e->getMessage() . "\n" );
27 return serialize($image->parsedPNGMetadata
);
31 function formatMetadata( $image ) {
39 function isAnimatedImage( $image ) {
40 $ser = $image->getMetadata();
42 $metadata = unserialize($ser);
43 if( $metadata['frameCount'] > 1 ) return true;
48 function getMetadataType( $image ) {
52 function isMetadataValid( $image, $metadata ) {
54 $data = unserialize( $metadata );
56 return (boolean
) $data;
63 function getLongDesc( $image ) {
65 $original = parent
::getLongDesc( $image );
68 $metadata = unserialize($image->getMetadata());
71 if( !$metadata ||
$metadata['frameCount'] <= 0 )
77 if ($metadata['loopCount'] == 0)
78 $info[] = wfMsgExt( 'file-info-png-looped', 'parseinline' );
79 elseif ($metadata['loopCount'] > 1)
80 $info[] = wfMsgExt( 'file-info-png-repeat', 'parseinline', $metadata['loopCount'] );
82 if ($metadata['frameCount'] > 0)
83 $info[] = wfMsgExt( 'file-info-png-frames', 'parseinline', $metadata['frameCount'] );
85 if ($metadata['duration'])
86 $info[] = $wgLang->formatTimePeriod( $metadata['duration'] );
88 return $wgLang->commaList( $info );