46 $version = is_int( $version ) ? $version : (int)explode(
';', $version, 2 )[0];
47 if ( $version < 1 || $version >= 2 ) {
51 if ( !isset( $metadata[
'MEDIAWIKI_EXIF_VERSION'] ) || $metadata[
'MEDIAWIKI_EXIF_VERSION'] !== 2 ) {
57 if ( isset( $metadata[
'Software'] )
58 && is_array( $metadata[
'Software'] )
59 && is_array( $metadata[
'Software'][0] )
60 && isset( $metadata[
'Software'][0][0] )
61 && isset( $metadata[
'Software'][0][1] )
63 $metadata[
'Software'] = $metadata[
'Software'][0][0] .
' (Version '
64 . $metadata[
'Software'][0][1] .
')';
70 if ( isset( $metadata[
'Contact'] ) ) {
72 is_array( $metadata[
'Contact'] ) ? $metadata[
'Contact'] : [ $metadata[
'Contact'] ]
77 if ( isset( $metadata[
'LocationShown'] ) && !is_string( $metadata[
'LocationShown'] ) ) {
78 unset( $metadata[
'LocationShown'] );
81 foreach ( $metadata as &$val ) {
82 if ( is_array( $val ) ) {
84 $val = $formatter->flattenArrayReal( $val,
'ul',
true );
88 $metadata[
'MEDIAWIKI_EXIF_VERSION'] = 1;
98 $showEXIF = MediaWikiServices::getInstance()->getMainConfig()->get( MainConfigNames::ShowEXIF );
100 # Metadata disabled and so an empty field is expected
103 $exif = $image->getMetadataArray();
105 wfDebug( __METHOD__ .
': error unserializing?' );
108 if ( $exif === [
'_error' => self::OLD_BROKEN_FILE ] ) {
109 # Old special value indicating that there is no Exif data in the file.
110 # or that there was an error well extracting the metadata.
111 wfDebug( __METHOD__ .
": back-compat version" );
115 if ( $exif === [
'_error' => self::BROKEN_FILE ] ) {
119 if ( !isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
122 if ( isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
123 && $exif[
'MEDIAWIKI_EXIF_VERSION'] === 1
126 wfDebug( __METHOD__ .
": back-compat version" );
130 # Wrong (non-compatible) version
131 wfDebug( __METHOD__ .
": wrong version" );
158 unset( $exif[
'MEDIAWIKI_EXIF_VERSION'] );
174 if ( $rotation === 90 || $rotation === 270 ) {
175 $width = $info[
'width'];
176 $info[
'width'] = $info[
'height'];
177 $info[
'height'] = $width;
199 $orientation = $file->getMetadataItem(
'Orientation' );
212 if ( $orientation ===
null ) {
216 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)
static version()
The version of the output format.
A class containing constants representing the names of configuration variables.
Interface for objects which can provide a MediaWiki context on request.