Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Willnecker <johannes@willnecker.com>2012-07-05 23:09:48 +0400
committerJörn Friedrich Dreyer <jfd@butonic.de>2012-07-10 18:58:37 +0400
commit3e53bf4a868405d1d5ef8ba0ecc07ecf5ebb3a59 (patch)
tree88d005e1448c7db989f3eff06290f9428ce09d0c /lib/image.php
parent91da4b05b72b118ad9f6ffb7f24fbe1aa5bc20fe (diff)
Fix for oc-972, oc-1144 and oc-1191
Diffstat (limited to 'lib/image.php')
-rw-r--r--lib/image.php80
1 files changed, 71 insertions, 9 deletions
diff --git a/lib/image.php b/lib/image.php
index e5c59bacdc5..1d4d63707f3 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -108,6 +108,56 @@ class OC_Image {
}
/**
+ * @brief Returns the width when the image orientation is top-left.
+ * @returns int
+ */
+ public function widthTopLeft() {
+ $o = $this->getOrientation();
+ OC_Log::write('core','OC_Image->widthTopLeft() Orientation: '.$o, OC_Log::DEBUG);
+ switch($o) {
+ case -1:
+ case 1:
+ case 2: // Not tested
+ case 3:
+ case 4: // Not tested
+ return $this->width();
+ break;
+ case 5: // Not tested
+ case 6:
+ case 7: // Not tested
+ case 8:
+ return $this->height();
+ break;
+ }
+ return $this->width();
+ }
+
+ /**
+ * @brief Returns the height when the image orientation is top-left.
+ * @returns int
+ */
+ public function heightTopLeft() {
+ $o = $this->getOrientation();
+ OC_Log::write('core','OC_Image->heightTopLeft() Orientation: '.$o, OC_Log::DEBUG);
+ switch($o) {
+ case -1:
+ case 1:
+ case 2: // Not tested
+ case 3:
+ case 4: // Not tested
+ return $this->height();
+ break;
+ case 5: // Not tested
+ case 6:
+ case 7: // Not tested
+ case 8:
+ return $this->width();
+ break;
+ }
+ return $this->height();
+ }
+
+ /**
* @brief Outputs the image.
* @returns bool
*/
@@ -209,34 +259,46 @@ class OC_Image {
/**
* (I'm open for suggestions on better method name ;)
- * @brief Fixes orientation based on EXIF data.
- * @returns bool.
+ * @brief Get the orientation based on EXIF data.
+ * @returns The orientation or -1 if no EXIF data is available.
*/
- public function fixOrientation() {
+ public function getOrientation() {
if(!is_callable('exif_read_data')){
OC_Log::write('core','OC_Image->fixOrientation() Exif module not enabled.', OC_Log::DEBUG);
- return false;
+ return -1;
}
if(!$this->valid()) {
OC_Log::write('core','OC_Image->fixOrientation() No image loaded.', OC_Log::DEBUG);
- return false;
+ return -1;
}
if(is_null($this->filepath) || !is_readable($this->filepath)) {
OC_Log::write('core','OC_Image->fixOrientation() No readable file path set.', OC_Log::DEBUG);
- return false;
+ return -1;
}
$exif = @exif_read_data($this->filepath, 'IFD0');
if(!$exif) {
- return false;
+ return -1;
}
if(!isset($exif['Orientation'])) {
- return true; // Nothing to fix
+ return -1;
}
- $o = $exif['Orientation'];
+ return $exif['Orientation'];
+ }
+
+ /**
+ * (I'm open for suggestions on better method name ;)
+ * @brief Fixes orientation based on EXIF data.
+ * @returns bool.
+ */
+ public function fixOrientation() {
+ $o = $this->getOrienation();
OC_Log::write('core','OC_Image->fixOrientation() Orientation: '.$o, OC_Log::DEBUG);
$rotate = 0;
$flip = false;
switch($o) {
+ case -1:
+ return false; //Nothing to fix
+ break;
case 1:
$rotate = 0;
$flip = false;