diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-06-22 11:28:20 +0200 |
commit | 9db190c7e736ec8d063187d4241b59feaf7dc2d1 (patch) | |
tree | 46d1a0dee7febef5c2d57a9f7b972be16a163b3d /includes/media/PNG.php | |
parent | 78677c7bbdcc9739f6c10c75935898a20e1acd9e (diff) |
update to MediaWiki 1.17.0
Diffstat (limited to 'includes/media/PNG.php')
-rw-r--r-- | includes/media/PNG.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/includes/media/PNG.php b/includes/media/PNG.php new file mode 100644 index 00000000..5197282c --- /dev/null +++ b/includes/media/PNG.php @@ -0,0 +1,82 @@ +<?php +/** + * Handler for PNG images. + * + * @file + * @ingroup Media + */ + +/** + * Handler for PNG images. + * + * @ingroup Media + */ +class PNGHandler extends BitmapHandler { + + function getMetadata( $image, $filename ) { + if ( !isset($image->parsedPNGMetadata) ) { + try { + $image->parsedPNGMetadata = PNGMetadataExtractor::getMetadata( $filename ); + } catch( Exception $e ) { + // Broken file? + wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" ); + return '0'; + } + } + + return serialize($image->parsedPNGMetadata); + + } + + function formatMetadata( $image ) { + return false; + } + + function isAnimatedImage( $image ) { + $ser = $image->getMetadata(); + if ($ser) { + $metadata = unserialize($ser); + if( $metadata['frameCount'] > 1 ) return true; + } + return false; + } + + function getMetadataType( $image ) { + return 'parsed-png'; + } + + 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'] <= 0 ) + return $original; + + $info = array(); + $info[] = $original; + + if ($metadata['loopCount'] == 0) + $info[] = wfMsgExt( 'file-info-png-looped', 'parseinline' ); + elseif ($metadata['loopCount'] > 1) + $info[] = wfMsgExt( 'file-info-png-repeat', 'parseinline', $metadata['loopCount'] ); + + if ($metadata['frameCount'] > 0) + $info[] = wfMsgExt( 'file-info-png-frames', 'parseinline', $metadata['frameCount'] ); + + if ($metadata['duration']) + $info[] = $wgLang->formatTimePeriod( $metadata['duration'] ); + + return $wgLang->commaList( $info ); + } + +} |