From ec7b55f5be67583e4b52c2a8d8c600f476a50e03 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 28 Nov 2014 09:25:40 +0100 Subject: [PATCH] Split bitmap providers into one per file --- lib/private/preview.php | 2 - lib/private/preview/bitmap.php | 92 +++++++---------------------- lib/private/preview/illustrator.php | 19 ++++++ lib/private/preview/pdf.php | 19 ++++++ lib/private/preview/photoshop.php | 19 ++++++ lib/private/preview/postscript.php | 19 ++++++ lib/private/preview/tiff.php | 19 ++++++ 7 files changed, 117 insertions(+), 72 deletions(-) create mode 100644 lib/private/preview/illustrator.php create mode 100644 lib/private/preview/pdf.php create mode 100644 lib/private/preview/photoshop.php create mode 100644 lib/private/preview/postscript.php create mode 100644 lib/private/preview/tiff.php diff --git a/lib/private/preview.php b/lib/private/preview.php index 696895cd3a..f6c8c485d0 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -16,8 +16,6 @@ namespace OC; use OC\Preview\Provider; use OCP\Files\NotFoundException; -require_once 'preview/bitmap.php'; - class Preview { //the thumbnail folder const THUMBNAILS_FOLDER = 'thumbnails'; diff --git a/lib/private/preview/bitmap.php b/lib/private/preview/bitmap.php index 4632285348..25f65cf7fc 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; +abstract class Bitmap extends Provider { + /** + * {@inheritDoc} + */ + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + $tmpPath = $fileview->toTmpFile($path); - class Bitmap extends Provider { + //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]'); - public function getMimeType() { - return null; + $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); + unlink($tmpPath); - //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; - } - - 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/'; - } - - } +} diff --git a/lib/private/preview/illustrator.php b/lib/private/preview/illustrator.php new file mode 100644 index 0000000000..e88c305f70 --- /dev/null +++ b/lib/private/preview/illustrator.php @@ -0,0 +1,19 @@ +