X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2FPhoto.php;h=30424747da82a33af4ee88c733e0b712f9967e0b;hb=6c7cf2a76677e0fdaee6a5e65d99c443260ca9a6;hp=e36fd46ca036b5e101f5d19dbf8353dfebd4a261;hpb=2dd8db7de880794db10664965713f8a46581bd7a;p=friendica.git diff --git a/include/Photo.php b/include/Photo.php index e36fd46ca0..30424747da 100644 --- a/include/Photo.php +++ b/include/Photo.php @@ -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; + } @@ -870,9 +873,9 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { $page_owner_nick = $r[0]['nickname']; -// To-Do: -// $default_cid = $r[0]['id']; -// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); + /// @TODO + /// $default_cid = $r[0]['id']; + /// $community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false); if ((strlen($imagedata) == 0) AND ($url == "")) { logger("No image data and no url provided", LOGGER_DEBUG); @@ -1013,3 +1016,4 @@ function store_photo($a, $uid, $imagedata = "", $url = "") { return($image); } +