diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-11-28 09:25:40 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-11-28 09:28:33 +0100 |
commit | ec7b55f5be67583e4b52c2a8d8c600f476a50e03 (patch) | |
tree | ae8426f3c2ac3b73b8647ceb37b88f05d75516dd /lib/private/preview/bitmap.php | |
parent | 3ec42ad59887deafd8705a687d3dd0885d4e2bbe (diff) | |
download | nextcloud-server-ec7b55f5be67583e4b52c2a8d8c600f476a50e03.tar.gz nextcloud-server-ec7b55f5be67583e4b52c2a8d8c600f476a50e03.zip |
Split bitmap providers into one per file
Diffstat (limited to 'lib/private/preview/bitmap.php')
-rw-r--r-- | lib/private/preview/bitmap.php | 96 |
1 files changed, 24 insertions, 72 deletions
diff --git a/lib/private/preview/bitmap.php b/lib/private/preview/bitmap.php index 46322853486..25f65cf7fc9 100644 --- a/lib/private/preview/bitmap.php +++ b/lib/private/preview/bitmap.php @@ -5,81 +5,33 @@ * later. * See the COPYING-README file. */ -namespace OC\Preview; - -use Imagick; - class Bitmap extends Provider { +namespace OC\Preview; - public function getMimeType() { - return null; +abstract class Bitmap extends Provider { + /** + * {@inheritDoc} + */ + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $tmpPath = $fileview->toTmpFile($path); + + //create imagick object from bitmap or vector file + try { + // Layer 0 contains either the bitmap or + // a flat representation of all vector layers + $bp = new \Imagick($tmpPath . '[0]'); + + $bp->setImageFormat('png'); + } catch (\Exception $e) { + \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); + return false; } - public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { - $tmpPath = $fileview->toTmpFile($path); - - //create imagick object from bitmap or vector file - try { - // Layer 0 contains either the bitmap or - // a flat representation of all vector layers - $bp = new Imagick($tmpPath . '[0]'); + unlink($tmpPath); - $bp->setImageFormat('png'); - } catch (\Exception $e) { - \OC_Log::write('core', $e->getmessage(), \OC_Log::ERROR); - return false; - } - - unlink($tmpPath); - - //new bitmap image object - $image = new \OC_Image($bp); - //check if image object is valid - return $image->valid() ? $image : false; - } + //new bitmap image object + $image = new \OC_Image($bp); + //check if image object is valid + return $image->valid() ? $image : false; } - - //.pdf - class PDF extends Bitmap { - - public function getMimeType() { - return '/application\/pdf/'; - } - - } - - //.tiff - class TIFF extends Bitmap { - - public function getMimeType() { - return '/image\/tiff/'; - } - - } - - //.ai - class Illustrator extends Bitmap { - - public function getMimeType() { - return '/application\/illustrator/'; - } - - } - - //.eps - class Postscript extends Bitmap { - - public function getMimeType() { - return '/application\/postscript/'; - } - - } - - //.psd - class Photoshop extends Bitmap { - - public function getMimeType() { - return '/application\/x-photoshop/'; - } - - } +} |