26use Wikimedia\RequestTimeout\TimeoutException;
34 private const BROKEN_FILE =
'0';
44 }
catch ( TimeoutException $e ) {
46 }
catch ( Exception $e ) {
48 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
50 return [
'metadata' => [
'_error' => self::BROKEN_FILE ] ];
54 'width' => $metadata[
'width'],
55 'height' => $metadata[
'height'],
56 'bits' => $metadata[
'bitDepth'],
57 'metadata' => array_diff_key(
59 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
87 if ( !isset( $meta[
'metadata'] ) ) {
90 unset( $meta[
'metadata'][
'_MW_PNG_VERSION'] );
92 return $meta[
'metadata'];
100 $metadata = $image->getMetadataArray();
101 return isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1;
118 $data = $image->getMetadataArray();
119 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
124 if ( !$data || isset( $data[
'_error'] ) ) {
125 wfDebug( __METHOD__ .
" invalid png metadata" );
130 if ( !isset( $data[
'metadata'][
'_MW_PNG_VERSION'] )
133 wfDebug( __METHOD__ .
" old but compatible png metadata" );
147 $original = parent::getLongDesc( $image );
149 $metadata = $image->getMetadataArray();
151 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
158 if ( $metadata[
'loopCount'] == 0 ) {
159 $info[] =
wfMessage(
'file-info-png-looped' )->parse();
160 } elseif ( $metadata[
'loopCount'] > 1 ) {
161 $info[] =
wfMessage(
'file-info-png-repeat' )->numParams( $metadata[
'loopCount'] )->parse();
164 if ( $metadata[
'frameCount'] > 0 ) {
165 $info[] =
wfMessage(
'file-info-png-frames' )->numParams( $metadata[
'frameCount'] )->parse();
168 if ( $metadata[
'duration'] ) {
169 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
172 return $wgLang->commaList( $info );
184 $metadata = $file->getMetadataArray();
186 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
190 return (
float)$metadata[
'duration'];
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgLang
Generic handler for bitmap images.
isFileMetadataValid( $image)
Check if the metadata is valid for this handler.
formatMetadata( $image, $context=false)
getCommonMetaArray(File $image)
Get a file type independent array of metadata.
supportsBucketing()
Returns whether or not this handler supports the chained generation of thumbnails according to bucket...
getLength( $file)
Return the duration of an APNG file.
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
getSizeAndMetadata( $state, $filename)
canAnimateThumbnail( $image)
We do not support making APNG thumbnails, so always false.
Interface for objects which can provide a MediaWiki context on request.