Split bitmap providers into one per file
This commit is contained in:
parent
3ec42ad598
commit
ec7b55f5be
|
@ -16,8 +16,6 @@ namespace OC;
|
||||||
use OC\Preview\Provider;
|
use OC\Preview\Provider;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
|
|
||||||
require_once 'preview/bitmap.php';
|
|
||||||
|
|
||||||
class Preview {
|
class Preview {
|
||||||
//the thumbnail folder
|
//the thumbnail folder
|
||||||
const THUMBNAILS_FOLDER = 'thumbnails';
|
const THUMBNAILS_FOLDER = 'thumbnails';
|
||||||
|
|
|
@ -5,16 +5,13 @@
|
||||||
* later.
|
* later.
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OC\Preview;
|
namespace OC\Preview;
|
||||||
|
|
||||||
use Imagick;
|
abstract class Bitmap extends Provider {
|
||||||
|
/**
|
||||||
class Bitmap extends Provider {
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public function getMimeType() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||||
$tmpPath = $fileview->toTmpFile($path);
|
$tmpPath = $fileview->toTmpFile($path);
|
||||||
|
|
||||||
|
@ -22,7 +19,7 @@ use Imagick;
|
||||||
try {
|
try {
|
||||||
// Layer 0 contains either the bitmap or
|
// Layer 0 contains either the bitmap or
|
||||||
// a flat representation of all vector layers
|
// a flat representation of all vector layers
|
||||||
$bp = new Imagick($tmpPath . '[0]');
|
$bp = new \Imagick($tmpPath . '[0]');
|
||||||
|
|
||||||
$bp->setImageFormat('png');
|
$bp->setImageFormat('png');
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -38,48 +35,3 @@ use Imagick;
|
||||||
return $image->valid() ? $image : false;
|
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/';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Preview;
|
||||||
|
|
||||||
|
//.ai
|
||||||
|
class Illustrator extends Bitmap {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMimeType() {
|
||||||
|
return '/application\/illustrator/';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Preview;
|
||||||
|
|
||||||
|
//.pdf
|
||||||
|
class PDF extends Bitmap {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMimeType() {
|
||||||
|
return '/application\/pdf/';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Preview;
|
||||||
|
|
||||||
|
//.psd
|
||||||
|
class Photoshop extends Bitmap {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMimeType() {
|
||||||
|
return '/application\/x-photoshop/';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Preview;
|
||||||
|
|
||||||
|
//.eps
|
||||||
|
class Postscript extends Bitmap {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMimeType() {
|
||||||
|
return '/application\/postscript/';
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2013-2014 Georg Ehrke georg@ownCloud.com
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Preview;
|
||||||
|
|
||||||
|
//.tiff
|
||||||
|
class TIFF extends Bitmap {
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getMimeType() {
|
||||||
|
return '/image\/tiff/';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue