26use Wikimedia\RequestTimeout\TimeoutException;
37 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' => $parsedGIFMetadata[
'width'],
53 'height' => $parsedGIFMetadata[
'height'],
54 'bits' => $parsedGIFMetadata[
'bits'],
55 'metadata' => array_diff_key(
57 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
83 if ( !isset( $meta[
'metadata'] ) ) {
86 unset( $meta[
'metadata'][
'_MW_GIF_VERSION'] );
88 return $meta[
'metadata'];
98 $metadata = $image->getMetadataArray();
99 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 0 ) {
100 return $image->getWidth() * $image->getHeight() * $metadata[
'frameCount'];
102 return $image->getWidth() * $image->getHeight();
110 $metadata = $image->getMetadataArray();
111 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
124 $maxAnimatedGifArea = MediaWikiServices::getInstance()->getMainConfig()
125 ->get( MainConfigNames::MaxAnimatedGifArea );
135 $data = $image->getMetadataArray();
136 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
141 if ( !$data || isset( $data[
'_error'] ) ) {
142 wfDebug( __METHOD__ .
" invalid GIF metadata" );
147 if ( !isset( $data[
'metadata'][
'_MW_GIF_VERSION'] )
150 wfDebug( __METHOD__ .
" old but compatible GIF metadata" );
165 $original = parent::getLongDesc( $image );
167 $metadata = $image->getMetadataArray();
169 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
177 if ( $metadata[
'looped'] ) {
178 $info[] =
wfMessage(
'file-info-gif-looped' )->parse();
181 if ( $metadata[
'frameCount'] > 1 ) {
182 $info[] =
wfMessage(
'file-info-gif-frames' )->numParams( $metadata[
'frameCount'] )->parse();
185 if ( $metadata[
'duration'] ) {
186 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
189 return $wgLang->commaList( $info );
201 $metadata =
$file->getMetadataArray();
203 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
206 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.
getLength( $file)
Return the duration of the GIF file.
canAnimateThumbnail( $file)
We cannot animate thumbnails that are bigger than a particular size.
formatMetadata( $image, $context=false)
getSizeAndMetadata( $state, $filename)
Get image size information and metadata array.
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
getCommonMetaArray(File $image)
Return the standard metadata elements for #filemetadata parser func.
A class containing constants representing the names of configuration variables.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.