24use Wikimedia\RequestTimeout\TimeoutException;
32 private const BROKEN_FILE =
'0';
42 }
catch ( TimeoutException $e ) {
44 }
catch ( Exception $e ) {
46 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
48 return [
'metadata' => [
'_error' => self::BROKEN_FILE ] ];
52 'width' => $metadata[
'width'],
53 'height' => $metadata[
'height'],
54 'bits' => $metadata[
'bitDepth'],
55 'metadata' => array_diff_key(
57 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
85 if ( !isset( $meta[
'metadata'] ) ) {
88 unset( $meta[
'metadata'][
'_MW_PNG_VERSION'] );
90 return $meta[
'metadata'];
98 $metadata = $image->getMetadataArray();
99 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
120 $data = $image->getMetadataArray();
121 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
126 if ( !$data || isset( $data[
'_error'] ) ) {
127 wfDebug( __METHOD__ .
" invalid png metadata" );
132 if ( !isset( $data[
'metadata'][
'_MW_PNG_VERSION'] )
135 wfDebug( __METHOD__ .
" old but compatible png metadata" );
149 $original = parent::getLongDesc( $image );
151 $metadata = $image->getMetadataArray();
153 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
160 if ( $metadata[
'loopCount'] == 0 ) {
161 $info[] =
wfMessage(
'file-info-png-looped' )->parse();
162 } elseif ( $metadata[
'loopCount'] > 1 ) {
163 $info[] =
wfMessage(
'file-info-png-repeat' )->numParams( $metadata[
'loopCount'] )->parse();
166 if ( $metadata[
'frameCount'] > 0 ) {
167 $info[] =
wfMessage(
'file-info-png-frames' )->numParams( $metadata[
'frameCount'] )->parse();
170 if ( $metadata[
'duration'] ) {
171 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
174 return $wgLang->commaList( $info );
186 $metadata =
$file->getMetadataArray();
188 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
191 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') &&! $wgCommandLineMode $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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.