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 return isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1;
116 $data = $image->getMetadataArray();
117 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
122 if ( !$data || isset( $data[
'_error'] ) ) {
123 wfDebug( __METHOD__ .
" invalid png metadata" );
128 if ( !isset( $data[
'metadata'][
'_MW_PNG_VERSION'] )
131 wfDebug( __METHOD__ .
" old but compatible png metadata" );
145 $original = parent::getLongDesc( $image );
147 $metadata = $image->getMetadataArray();
149 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
156 if ( $metadata[
'loopCount'] == 0 ) {
157 $info[] =
wfMessage(
'file-info-png-looped' )->parse();
158 } elseif ( $metadata[
'loopCount'] > 1 ) {
159 $info[] =
wfMessage(
'file-info-png-repeat' )->numParams( $metadata[
'loopCount'] )->parse();
162 if ( $metadata[
'frameCount'] > 0 ) {
163 $info[] =
wfMessage(
'file-info-png-frames' )->numParams( $metadata[
'frameCount'] )->parse();
166 if ( $metadata[
'duration'] ) {
167 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
170 return $wgLang->commaList( $info );
182 $metadata =
$file->getMetadataArray();
184 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
188 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.