35 $version = is_int( $version ) ? $version : (int)explode(
';', $version, 2 )[0];
36 if ( $version < 1 || $version >= 2 ) {
40 if ( !isset( $metadata[
'MEDIAWIKI_EXIF_VERSION'] ) || $metadata[
'MEDIAWIKI_EXIF_VERSION'] !== 2 ) {
46 if ( isset( $metadata[
'Software'] )
47 && is_array( $metadata[
'Software'] )
48 && is_array( $metadata[
'Software'][0] )
49 && isset( $metadata[
'Software'][0][0] )
50 && isset( $metadata[
'Software'][0][1] )
52 $metadata[
'Software'] = $metadata[
'Software'][0][0] .
' (Version '
53 . $metadata[
'Software'][0][1] .
')';
59 if ( isset( $metadata[
'Contact'] ) ) {
61 is_array( $metadata[
'Contact'] ) ? $metadata[
'Contact'] : [ $metadata[
'Contact'] ]
66 foreach ( [
'LocationShown',
'LocationCreated' ] as $metadataKey ) {
67 if ( isset( $metadata[ $metadataKey ] ) && !is_string( $metadata[ $metadataKey ] ) ) {
68 unset( $metadata[ $metadataKey ] );
72 foreach ( $metadata as &$val ) {
73 if ( is_array( $val ) ) {
75 $val = $formatter->flattenArrayReal( $val,
'ul',
true );
79 $metadata[
'MEDIAWIKI_EXIF_VERSION'] = 1;
91 # Metadata disabled and so an empty field is expected
94 $exif = $image->getMetadataArray();
96 wfDebug( __METHOD__ .
': error unserializing?' );
99 if ( $exif === [
'_error' => self::OLD_BROKEN_FILE ] ) {
100 # Old special value indicating that there is no Exif data in the file.
101 # or that there was an error well extracting the metadata.
102 wfDebug( __METHOD__ .
": back-compat version" );
106 if ( $exif === [
'_error' => self::BROKEN_FILE ] ) {
110 if ( !isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
113 if ( isset( $exif[
'MEDIAWIKI_EXIF_VERSION'] )
114 && $exif[
'MEDIAWIKI_EXIF_VERSION'] === 1
117 wfDebug( __METHOD__ .
": back-compat version" );
121 # Wrong (non-compatible) version
122 wfDebug( __METHOD__ .
": wrong version" );
150 unset( $exif[
'MEDIAWIKI_EXIF_VERSION'] );
172 if ( $rotation === 90 || $rotation === 270 ) {
173 $width = $info[
'width'];
174 $info[
'width'] = $info[
'height'];
175 $info[
'height'] = $width;
197 $orientation = $file->getMetadataItem(
'Orientation' );
210 if ( $orientation ===
null ) {
214 switch ( $orientation ) {
228class_alias( ExifBitmapHandler::class,
'ExifBitmapHandler' );
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
A class containing constants representing the names of configuration variables.
const ShowEXIF
Name constant for the ShowEXIF setting, for use with Config::get()
Interface for objects which can provide a MediaWiki context on request.