25use Wikimedia\RequestTimeout\TimeoutException;
41 }
catch ( TimeoutException $e ) {
43 }
catch ( Exception $e ) {
45 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
51 'width' => $parsedGIFMetadata[
'width'],
52 'height' => $parsedGIFMetadata[
'height'],
53 'bits' => $parsedGIFMetadata[
'bits'],
54 'metadata' => array_diff_key(
56 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
82 if ( !isset( $meta[
'metadata'] ) ) {
85 unset( $meta[
'metadata'][
'_MW_GIF_VERSION'] );
87 return $meta[
'metadata'];
97 $metadata = $image->getMetadataArray();
98 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 0 ) {
99 return $image->getWidth() * $image->getHeight() * $metadata[
'frameCount'];
101 return $image->getWidth() * $image->getHeight();
110 $metadata = $image->getMetadataArray();
111 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
124 $maxAnimatedGifArea = MediaWikiServices::getInstance()->getMainConfig()->get(
'MaxAnimatedGifArea' );
134 $data = $image->getMetadataArray();
135 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
140 if ( !$data || isset( $data[
'_error'] ) ) {
141 wfDebug( __METHOD__ .
" invalid GIF metadata" );
146 if ( !isset( $data[
'metadata'][
'_MW_GIF_VERSION'] )
149 wfDebug( __METHOD__ .
" old but compatible GIF metadata" );
164 $original = parent::getLongDesc( $image );
166 $metadata = $image->getMetadataArray();
168 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
176 if ( $metadata[
'looped'] ) {
177 $info[] =
wfMessage(
'file-info-gif-looped' )->parse();
180 if ( $metadata[
'frameCount'] > 1 ) {
181 $info[] =
wfMessage(
'file-info-gif-frames' )->numParams( $metadata[
'frameCount'] )->parse();
184 if ( $metadata[
'duration'] ) {
185 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
188 return $wgLang->commaList( $info );
200 $metadata =
$file->getMetadataArray();
202 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
205 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)
const BROKEN_FILE
Value to store in img_metadata if there was error extracting metadata.
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.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.