X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fmedia%2FPNG.php;h=e297fe1b45c89f0f7326a51080948c0d72cc0c81;hb=6da98ee84b844c9fba0d6c7fa76d8fc50bf2abbc;hp=c3f08325bc15887498452bbb394ac71c149553fa;hpb=6b1a173f07f1a04188735f4688ce6335da14c3b7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/PNG.php b/includes/media/PNG.php index c3f08325bc..e297fe1b45 100644 --- a/includes/media/PNG.php +++ b/includes/media/PNG.php @@ -175,9 +175,29 @@ class PNGHandler extends BitmapHandler { return $wgLang->commaList( $info ); } + /** + * Return the duration of an APNG file. + * + * Shown in the &query=imageinfo&iiprop=size api query. + * + * @param $file File + * @return float The duration of the file. + */ + public function getLength( $file ) { + $serMeta = $file->getMetadata(); + MediaWiki\suppressWarnings(); + $metadata = unserialize( $serMeta ); + MediaWiki\restoreWarnings(); + + if ( !$metadata || !isset( $metadata['duration'] ) || !$metadata['duration'] ) { + return 0.0; + } else { + return (float)$metadata['duration']; + } + } + // PNGs should be easy to support, but it will need some sharpening applied // and another user test to check if the perceived quality change is noticeable - public function supportsBucketing() { return false; }