Merge "CologneBlue rewrite: get rid of some extra ugly HTML"
[lhc/web/wiklou.git] / includes / media / ExifBitmap.php
index 6b4bf7a..34a1f51 100644 (file)
@@ -1,5 +1,22 @@
 <?php
 /**
+ * Handler for bitmap images with exif metadata.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup Media
  */
@@ -34,8 +51,8 @@ class ExifBitmapHandler extends BitmapHandler {
 
                // Treat Software as a special case because in can contain
                // an array of (SoftwareName, Version).
-               if (isset( $metadata['Software'] ) 
-                       && is_array( $metadata['Software'] ) 
+               if (isset( $metadata['Software'] )
+                       && is_array( $metadata['Software'] )
                        && is_array( $metadata['Software'][0])
                        && isset( $metadata['Software'][0][0] )
                        && isset( $metadata['Software'][0][1])
@@ -134,12 +151,17 @@ class ExifBitmapHandler extends BitmapHandler {
         * @return array
         */
        function getImageSize( $image, $path ) {
+               global $wgEnableAutoRotation;
                $gis = parent::getImageSize( $image, $path );
-               
-               // Don't just call $image->getMetadata(); File::getPropsFromPath() calls us with a bogus object.
+
+               // Don't just call $image->getMetadata(); FSFile::getPropsFromPath() calls us with a bogus object.
                // This may mean we read EXIF data twice on initial upload.
-               $meta = $this->getMetadata( $image, $path );
-               $rotation = $this->getRotationForExif( $meta );
+               if ( $wgEnableAutoRotation ) {
+                       $meta = $this->getMetadata( $image, $path );
+                       $rotation = $this->getRotationForExif( $meta );
+               } else {
+                       $rotation = 0;
+               }
 
                if ($rotation == 90 || $rotation == 270) {
                        $width = $gis[0];
@@ -162,6 +184,11 @@ class ExifBitmapHandler extends BitmapHandler {
         * @return int 0, 90, 180 or 270
         */
        public function getRotation( $file ) {
+               global $wgEnableAutoRotation;
+               if ( !$wgEnableAutoRotation ) {
+                       return 0;
+               }
+
                $data = $file->getMetadata();
                return $this->getRotationForExif( $data );
        }
@@ -172,7 +199,8 @@ class ExifBitmapHandler extends BitmapHandler {
         *
         * @param string $data
         * @return int 0, 90, 180 or 270
-        * @fixme orientation can include flipping as well; see if this is an issue!
+        * @todo FIXME orientation can include flipping as well; see if this is an
+        * issue!
         */
        protected function getRotationForExif( $data ) {
                if ( !$data ) {