17use Wikimedia\RequestTimeout\TimeoutException;
28 private const BROKEN_FILE =
'0';
34 }
catch ( TimeoutException $e ) {
36 }
catch ( Exception $e ) {
38 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
40 return [
'metadata' => [
'_error' => self::BROKEN_FILE ] ];
44 'width' => $parsedGIFMetadata[
'width'],
45 'height' => $parsedGIFMetadata[
'height'],
46 'bits' => $parsedGIFMetadata[
'bits'],
47 'metadata' => array_diff_key(
49 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
75 if ( !isset( $meta[
'metadata'] ) ) {
78 unset( $meta[
'metadata'][
'_MW_GIF_VERSION'] );
80 return $meta[
'metadata'];
90 $metadata = $image->getMetadataArray();
91 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 0 ) {
92 return $image->getWidth() * $image->getHeight() * $metadata[
'frameCount'];
94 return $image->getWidth() * $image->getHeight();
102 $metadata = $image->getMetadataArray();
103 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
119 return $this->
getImageArea( $file ) <= $maxAnimatedGifArea;
129 $data = $image->getMetadataArray();
130 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
135 if ( !$data || isset( $data[
'_error'] ) ) {
136 wfDebug( __METHOD__ .
" invalid GIF metadata" );
141 if ( !isset( $data[
'metadata'][
'_MW_GIF_VERSION'] )
144 wfDebug( __METHOD__ .
" old but compatible GIF metadata" );
159 $original = parent::getLongDesc( $image );
161 $metadata = $image->getMetadataArray();
163 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
171 if ( $metadata[
'looped'] ) {
172 $info[] =
wfMessage(
'file-info-gif-looped' )->parse();
175 if ( $metadata[
'frameCount'] > 1 ) {
176 $info[] =
wfMessage(
'file-info-gif-frames' )->numParams( $metadata[
'frameCount'] )->parse();
179 if ( $metadata[
'duration'] ) {
180 $info[] = htmlspecialchars(
$wgLang->formatTimePeriod( $metadata[
'duration'] ), ENT_QUOTES );
183 return $wgLang->commaList( $info );
195 $metadata = $file->getMetadataArray();
197 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
200 return (
float)$metadata[
'duration'];
205class_alias( GIFHandler::class,
'GIFHandler' );
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(MW_ENTRY_POINT==='index') if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgLang
A class containing constants representing the names of configuration variables.
const MaxAnimatedGifArea
Name constant for the MaxAnimatedGifArea setting, for use with Config::get()
Interface for objects which can provide a MediaWiki context on request.