const BROKEN_FILE = '0';
/**
- * @param File $image
+ * @param File|FSFile $image
* @param string $filename
* @return string
*/
$meta = $image->getMetadata();
if ( !$meta ) {
- return array();
+ return [];
}
$meta = unserialize( $meta );
if ( !isset( $meta['metadata'] ) ) {
- return array();
+ return [];
}
unset( $meta['metadata']['_MW_PNG_VERSION'] );
return $original;
}
- $info = array();
+ $info = [];
$info[] = $original;
if ( $metadata['loopCount'] == 0 ) {
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;
}