44 $version = is_int( $version ) ? $version : intval( explode(
';', $version, 2 )[0] );
45 if ( $version < 1 || $version >= 2 ) {
49 if ( !isset( $metadata[
'MEDIAWIKI_EXIF_VERSION'] ) || $metadata[
'MEDIAWIKI_EXIF_VERSION'] != 2 ) {
55 if ( isset( $metadata[
'Software'] )
56 && is_array( $metadata[
'Software'] )
57 && is_array( $metadata[
'Software'][0] )
58 && isset( $metadata[
'Software'][0][0] )
59 && isset( $metadata[
'Software'][0][1] )
61 $metadata[
'Software'] = $metadata[
'Software'][0][0] .
' (Version '
62 . $metadata[
'Software'][0][1] .
')';
68 if ( isset( $metadata[
'Contact'] ) ) {
70 is_array( $metadata[
'Contact'] ) ? $metadata[
'Contact'] : [ $metadata[
'Contact'] ]
75 if ( isset( $metadata[
'LocationShown'] ) && !is_string( $metadata[
'LocationShown'] ) ) {
76 unset( $metadata[
'LocationShown'] );
79 foreach ( $metadata as &$val ) {
80 if ( is_array( $val ) ) {
82 $val = $formatter->flattenArrayReal( $val,
'ul',
true );
85 $metadata[
'MEDIAWIKI_EXIF_VERSION'] = 1;
95 $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::ShowEXIF );
97 # Metadata disabled and so an empty field is expected
100 $exif = $image->getMetadataArray();
102 wfDebug( __METHOD__ .
': error unserializing?' );
105 if ( $exif === [
'_error' => self::OLD_BROKEN_FILE ] ) {
106 # Old special value indicating that there is no Exif data in the file.
107 # or that there was an error well extracting the metadata.
108 wfDebug( __METHOD__ .
": back-compat version" );
112 if ( $exif === [
'_error' => self::BROKEN_FILE ] ) {
116 if ( !isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
119 if ( isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
120 && $exif[
'MEDIAWIKI_EXIF_VERSION'] == 1
123 wfDebug( __METHOD__ .
": back-compat version" );
127 # Wrong (non-compatible) version
128 wfDebug( __METHOD__ .
": wrong version" );
151 $exif =
$file->getMetadataArray();
155 unset( $exif[
'MEDIAWIKI_EXIF_VERSION'] );
171 if ( $rotation == 90 || $rotation == 270 ) {
172 $width = $info[
'width'];
173 $info[
'width'] = $info[
'height'];
174 $info[
'height'] = $width;
196 $orientation =
$file->getMetadataItem(
'Orientation' );
209 if ( $orientation ===
null ) {
213 switch ( $orientation ) {
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Generic handler for bitmap images.
Stuff specific to JPEG and (built-in) TIFF handler.
getRotationForExifFromOrientation( $orientation)
Given a chunk of serialized Exif metadata, return the orientation as degrees of rotation.
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
applyExifRotation( $info, $metadata)
const OLD_BROKEN_FILE
Outdated error extracting metadata.
convertMetadataVersion( $metadata, $version=1)
Convert metadata version.
getRotation( $file)
On supporting image formats, try to read out the low-level orientation of the file and return the ang...
isFileMetadataValid( $image)
const BROKEN_FILE
Error extracting metadata.
formatMetadata( $image, $context=false)
Implements some public methods and some protected utility functions which are required by multiple ch...
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.