]> git.mxchange.org Git - friendica.git/blobdiff - include/Photo.php
add the module to the page title
[friendica.git] / include / Photo.php
index 0adc55258bac8a0d2f2ce5eedf9d72105d72d3e4..9732801c9a3d8fbe18a0bbfe20c2ca11214b5d7e 100644 (file)
@@ -345,38 +345,37 @@ class Photo {
     }
 
     public function orient($filename) {
-        if ($this->is_imagick()) {
-            // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
-            $orientation = $this->image->getImageOrientation();
-            switch ($orientation) {
-            case imagick::ORIENTATION_BOTTOMRIGHT:
-                $this->image->rotateimage("#000", 180);
-                break;
-            case imagick::ORIENTATION_RIGHTTOP:
-                $this->image->rotateimage("#000", 90);
-                break;
-            case imagick::ORIENTATION_LEFTBOTTOM:
-                $this->image->rotateimage("#000", -90);
-                break;
-            }
-
-            $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
-            return TRUE;
-        }
+       if ($this->is_imagick()) {
+               // based off comment on http://php.net/manual/en/imagick.getimageorientation.php
+               $orientation = $this->image->getImageOrientation();
+               switch ($orientation) {
+               case imagick::ORIENTATION_BOTTOMRIGHT:
+                   $this->image->rotateimage("#000", 180);
+                   break;
+               case imagick::ORIENTATION_RIGHTTOP:
+                   $this->image->rotateimage("#000", 90);
+                   break;
+               case imagick::ORIENTATION_LEFTBOTTOM:
+                   $this->image->rotateimage("#000", -90);
+                   break;
+               }
+
+               $this->image->setImageOrientation(imagick::ORIENTATION_TOPLEFT);
+               return TRUE;
+       }
        // based off comment on http://php.net/manual/en/function.imagerotate.php
 
        if(!$this->is_valid())
-           return FALSE;
+               return FALSE;
 
        if( (! function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg') )
-           return;
-
-       $exif = @exif_read_data($filename);
+               return;
 
-               if(! $exif)
-                       return;
+       $exif = @exif_read_data($filename,null,true);
+       if(! $exif)
+               return;
 
-       $ort = $exif['Orientation'];
+       $ort = $exif['IFD0']['Orientation'];
 
        switch($ort)
        {
@@ -413,6 +412,10 @@ class Photo {
                $this->rotate(90);
                break;
        }
+
+       //      logger('exif: ' . print_r($exif,true));
+       return $exif;
+
     }
 
 
@@ -1014,14 +1017,3 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
        return($image);
 }
 
-function formatBytes($bytes, $precision = 2) { 
-        $units = array('B', 'KB', 'MB', 'GB', 'TB'); 
-
-       $bytes = max($bytes, 0); 
-       $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); 
-       $pow = min($pow, count($units) - 1); 
-
-       $bytes /= pow(1024, $pow);
-
-       return round($bytes, $precision) . ' ' . $units[$pow]; 
-}