diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-07-10 16:53:09 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2012-07-10 16:58:37 +0200 |
commit | acb96123326460316290257cb05553f6a284ba04 (patch) | |
tree | 708527d83e5f76e593870ae5aa9ae8c86eb53824 /apps/gallery | |
parent | 02c9b03b8e29303090e159160b011bdac1dc4d51 (diff) | |
download | nextcloud-server-acb96123326460316290257cb05553f6a284ba04.tar.gz nextcloud-server-acb96123326460316290257cb05553f6a284ba04.zip |
fix thumbnail size calculation, use const for THUMBNAIL_HEIGHT
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/lib/managers.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/apps/gallery/lib/managers.php b/apps/gallery/lib/managers.php index 9ed1938742e..3b6f754fc2d 100644 --- a/apps/gallery/lib/managers.php +++ b/apps/gallery/lib/managers.php @@ -2,7 +2,7 @@ namespace OC\Pictures; -class DatabaseManager { +class DatabaseManager { private static $instance = null; protected $cache = array(); const TAG = 'DatabaseManager'; @@ -62,6 +62,7 @@ class ThumbnailsManager { private static $instance = null; const TAG = 'ThumbnailManager'; + const THUMBNAIL_HEIGHT = 150; public static function getInstance() { if (self::$instance === null) @@ -81,27 +82,23 @@ class ThumbnailsManager { $image = new \OC_Image(); $image->loadFromFile(\OC_Filesystem::getLocalFile($path)); if (!$image->valid()) return false; - + $image->fixOrientation(); - - $ret = $image->preciseResize($this->getThumbnailWidth($image), $this->getThumbnailHeight($image)); + + $ret = $image->preciseResize( floor((self::THUMBNAIL_HEIGHT*$image->width())/$image->height()), self::THUMBNAIL_HEIGHT ); if (!$ret) { \OC_Log::write(self::TAG, 'Couldn\'t resize image', \OC_Log::ERROR); unset($image); return false; } - + $image->save($gallery_path.'/'.$path); return $image; } public function getThumbnailWidth($image) { - return floor((150*$image->widthTopLeft())/$image->heightTopLeft()); - } - - public function getThumbnailHeight($image) { - return 150; + return floor((self::THUMBNAIL_HEIGHT*$image->widthTopLeft())/$image->heightTopLeft()); } public function getThumbnailInfo($path) { @@ -116,7 +113,7 @@ class ThumbnailsManager { if (!$image->valid()) { return false; } - $arr = DatabaseManager::getInstance()->setFileData($path, $this->getThumbnailWidth($image), $this->getThumbnailHeight($image)); + $arr = DatabaseManager::getInstance()->setFileData($path, $this->getThumbnailWidth($image), self::THUMBNAIL_HEIGHT); } $ret = array('filepath' => $arr['path'], 'width' => $arr['width'], |