X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmedia%2FExif.php;h=bdacbc86d95cb1c0ee264c92c295a0bdb89ea3ad;hb=cbc5ea8f3b86c5bc7852bd708fc59b918cb40bf9;hp=f5dc020c8d6b197091da2c9a153851c9c7f072cf;hpb=90db14df05c04502316f15faf35e670358dd0b78;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/Exif.php b/includes/media/Exif.php index f5dc020c8d..bdacbc86d9 100644 --- a/includes/media/Exif.php +++ b/includes/media/Exif.php @@ -104,6 +104,7 @@ class Exif { * * @param $file String: filename. * @param $byteOrder String Type of byte ordering either 'BE' (Big Endian) or 'LE' (Little Endian). Default ''. + * @throws MWException * @todo FIXME: The following are broke: * SubjectArea. Need to test the more obscure tags. * @@ -370,6 +371,12 @@ class Exif { $this->exifGPStoNumber( 'GPSDestLongitude' ); if ( isset( $this->mFilteredExifData['GPSAltitude'] ) && isset( $this->mFilteredExifData['GPSAltitudeRef'] ) ) { + + // We know altitude data is a / from the validation functions ran earlier. + // But multiplying such a string by -1 doesn't work well, so convert. + list( $num, $denom ) = explode( '/', $this->mFilteredExifData['GPSAltitude'] ); + $this->mFilteredExifData['GPSAltitude'] = $num / $denom; + if ( $this->mFilteredExifData['GPSAltitudeRef'] === "\1" ) { $this->mFilteredExifData['GPSAltitude'] *= - 1; } @@ -382,7 +389,7 @@ class Exif { $this->charCodeString( 'UserComment' ); $this->charCodeString( 'GPSProcessingMethod'); $this->charCodeString( 'GPSAreaInformation' ); - + //ComponentsConfiguration should really be an array instead of a string... //This turns a string of binary numbers into an array of numbers. @@ -395,7 +402,7 @@ class Exif { $ccVals['_type'] = 'ol'; //this is for formatting later. $this->mFilteredExifData['ComponentsConfiguration'] = $ccVals; } - + //GPSVersion(ID) is treated as the wrong type by php exif support. //Go through each byte turning it into a version string. //For example: "\x02\x02\x00\x00" -> "2.2.0.0" @@ -444,8 +451,7 @@ class Exif { } $charCode = substr( $this->mFilteredExifData[$prop], 0, 8); $val = substr( $this->mFilteredExifData[$prop], 8); - - + switch ($charCode) { case "\x4A\x49\x53\x00\x00\x00\x00\x00": //JIS @@ -474,7 +480,7 @@ class Exif { wfRestoreWarnings(); } } - + //trim and check to make sure not only whitespace. $val = trim($val); if ( strlen( $val ) === 0 ) { @@ -742,10 +748,10 @@ class Exif { return false; } if( $count > 1 ) { - foreach( $val as $v ) { + foreach( $val as $v ) { if( !$this->validate( $section, $tag, $v, true ) ) { - return false; - } + return false; + } } return true; }