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();
111 $metadata = $image->getMetadataArray();
112 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
125 $maxAnimatedGifArea = MediaWikiServices::getInstance()->getMainConfig()
126 ->get( MainConfigNames::MaxAnimatedGifArea );
136 $data = $image->getMetadataArray();
137 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
142 if ( !$data || isset( $data[
'_error'] ) ) {
143 wfDebug( __METHOD__ .
" invalid GIF metadata" );
148 if ( !isset( $data[
'metadata'][
'_MW_GIF_VERSION'] )
151 wfDebug( __METHOD__ .
" old but compatible GIF metadata" );
166 $original = parent::getLongDesc( $image );
168 $metadata = $image->getMetadataArray();
170 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
178 if ( $metadata[
'looped'] ) {
179 $info[] =
wfMessage(
'file-info-gif-looped' )->parse();
182 if ( $metadata[
'frameCount'] > 1 ) {
183 $info[] =
wfMessage(
'file-info-gif-frames' )->numParams( $metadata[
'frameCount'] )->parse();
186 if ( $metadata[
'duration'] ) {
187 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
190 return $wgLang->commaList( $info );
202 $metadata =
$file->getMetadataArray();
204 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
207 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.