25use Wikimedia\RequestTimeout\TimeoutException;
33 private const BROKEN_FILE =
'0';
43 }
catch ( TimeoutException $e ) {
45 }
catch ( Exception $e ) {
47 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
49 return [
'metadata' => [
'_error' => self::BROKEN_FILE ] ];
53 'width' => $metadata[
'width'],
54 'height' => $metadata[
'height'],
55 'bits' => $metadata[
'bitDepth'],
56 'metadata' => array_diff_key(
58 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
86 if ( !isset( $meta[
'metadata'] ) ) {
89 unset( $meta[
'metadata'][
'_MW_PNG_VERSION'] );
91 return $meta[
'metadata'];
99 $metadata = $image->getMetadataArray();
100 return isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1;
117 $data = $image->getMetadataArray();
118 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
123 if ( !$data || isset( $data[
'_error'] ) ) {
124 wfDebug( __METHOD__ .
" invalid png metadata" );
129 if ( !isset( $data[
'metadata'][
'_MW_PNG_VERSION'] )
132 wfDebug( __METHOD__ .
" old but compatible png metadata" );
146 $original = parent::getLongDesc( $image );
148 $metadata = $image->getMetadataArray();
150 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
157 if ( $metadata[
'loopCount'] == 0 ) {
158 $info[] =
wfMessage(
'file-info-png-looped' )->parse();
159 } elseif ( $metadata[
'loopCount'] > 1 ) {
160 $info[] =
wfMessage(
'file-info-png-repeat' )->numParams( $metadata[
'loopCount'] )->parse();
163 if ( $metadata[
'frameCount'] > 0 ) {
164 $info[] =
wfMessage(
'file-info-png-frames' )->numParams( $metadata[
'frameCount'] )->parse();
167 if ( $metadata[
'duration'] ) {
168 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
171 return $wgLang->commaList( $info );
183 $metadata = $file->getMetadataArray();
185 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
189 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.
Implements some public methods and some protected utility functions which are required by multiple ch...
getMetadataArray()
Get the unserialized handler-specific metadata STUB.
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.