24use Wikimedia\RequestTimeout\TimeoutException;
40 }
catch ( TimeoutException $e ) {
42 }
catch ( Exception $e ) {
44 wfDebug( __METHOD__ .
': ' . $e->getMessage() );
50 'width' => $parsedGIFMetadata[
'width'],
51 'height' => $parsedGIFMetadata[
'height'],
52 'bits' => $parsedGIFMetadata[
'bits'],
53 'metadata' => array_diff_key(
55 [
'width' =>
true,
'height' =>
true,
'bits' =>
true ]
81 if ( !isset( $meta[
'metadata'] ) ) {
84 unset( $meta[
'metadata'][
'_MW_GIF_VERSION'] );
86 return $meta[
'metadata'];
96 $metadata = $image->getMetadataArray();
97 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 0 ) {
98 return $image->getWidth() * $image->getHeight() * $metadata[
'frameCount'];
100 return $image->getWidth() * $image->getHeight();
109 $metadata = $image->getMetadataArray();
110 if ( isset( $metadata[
'frameCount'] ) && $metadata[
'frameCount'] > 1 ) {
133 $data = $image->getMetadataArray();
134 if ( $data === [
'_error' => self::BROKEN_FILE ] ) {
139 if ( !$data || isset( $data[
'_error'] ) ) {
140 wfDebug( __METHOD__ .
" invalid GIF metadata" );
145 if ( !isset( $data[
'metadata'][
'_MW_GIF_VERSION'] )
148 wfDebug( __METHOD__ .
" old but compatible GIF metadata" );
163 $original = parent::getLongDesc( $image );
165 $metadata = $image->getMetadataArray();
167 if ( !$metadata || isset( $metadata[
'_error'] ) || $metadata[
'frameCount'] <= 0 ) {
175 if ( $metadata[
'looped'] ) {
176 $info[] =
wfMessage(
'file-info-gif-looped' )->parse();
179 if ( $metadata[
'frameCount'] > 1 ) {
180 $info[] =
wfMessage(
'file-info-gif-frames' )->numParams( $metadata[
'frameCount'] )->parse();
183 if ( $metadata[
'duration'] ) {
184 $info[] =
$wgLang->formatTimePeriod( $metadata[
'duration'] );
187 return $wgLang->commaList( $info );
199 $metadata =
$file->getMetadataArray();
201 if ( !$metadata || !isset( $metadata[
'duration'] ) || !$metadata[
'duration'] ) {
204 return (
float)$metadata[
'duration'];
$wgMaxAnimatedGifArea
Force thumbnailing of animated GIFs above this size to a single frame instead of an animated thumbnai...
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.
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.