@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.tiff |
| 27 | 27 | class TIFF extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType(): string { |
|
| 32 | - return '/image\/tiff/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType(): string { |
|
| 32 | + return '/image\/tiff/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class BMP extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType(): string { |
|
| 30 | - return '/image\/bmp/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType(): string { |
|
| 30 | + return '/image\/bmp/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.ai |
| 27 | 27 | class Illustrator extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType(): string { |
|
| 32 | - return '/application\/illustrator/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType(): string { |
|
| 32 | + return '/application\/illustrator/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -25,10 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | //.eps |
| 27 | 27 | class Postscript extends Bitmap { |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getMimeType(): string { |
|
| 32 | - return '/application\/postscript/'; |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getMimeType(): string { |
|
| 32 | + return '/application\/postscript/'; |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class GIF extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType(): string { |
|
| 30 | - return '/image\/gif/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType(): string { |
|
| 30 | + return '/image\/gif/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | $content = stream_get_contents($file->fopen('r')); |
| 48 | 48 | if (substr($content, 0, 5) !== '<?xml') { |
| 49 | - $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; |
|
| 49 | + $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'.$content; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Do not parse SVG files with references |
@@ -32,50 +32,50 @@ |
||
| 32 | 32 | use Psr\Log\LoggerInterface; |
| 33 | 33 | |
| 34 | 34 | class SVG extends ProviderV2 { |
| 35 | - /** |
|
| 36 | - * {@inheritDoc} |
|
| 37 | - */ |
|
| 38 | - public function getMimeType(): string { |
|
| 39 | - return '/image\/svg\+xml/'; |
|
| 40 | - } |
|
| 35 | + /** |
|
| 36 | + * {@inheritDoc} |
|
| 37 | + */ |
|
| 38 | + public function getMimeType(): string { |
|
| 39 | + return '/image\/svg\+xml/'; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * {@inheritDoc} |
|
| 44 | - */ |
|
| 45 | - public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
| 46 | - try { |
|
| 47 | - $svg = new \Imagick(); |
|
| 48 | - $svg->setBackgroundColor(new \ImagickPixel('transparent')); |
|
| 42 | + /** |
|
| 43 | + * {@inheritDoc} |
|
| 44 | + */ |
|
| 45 | + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { |
|
| 46 | + try { |
|
| 47 | + $svg = new \Imagick(); |
|
| 48 | + $svg->setBackgroundColor(new \ImagickPixel('transparent')); |
|
| 49 | 49 | |
| 50 | - $content = stream_get_contents($file->fopen('r')); |
|
| 51 | - if (substr($content, 0, 5) !== '<?xml') { |
|
| 52 | - $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; |
|
| 53 | - } |
|
| 50 | + $content = stream_get_contents($file->fopen('r')); |
|
| 51 | + if (substr($content, 0, 5) !== '<?xml') { |
|
| 52 | + $content = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . $content; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - // Do not parse SVG files with references |
|
| 56 | - if (stripos($content, 'xlink:href') !== false) { |
|
| 57 | - return null; |
|
| 58 | - } |
|
| 55 | + // Do not parse SVG files with references |
|
| 56 | + if (stripos($content, 'xlink:href') !== false) { |
|
| 57 | + return null; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $svg->readImageBlob($content); |
|
| 61 | - $svg->setImageFormat('png32'); |
|
| 62 | - } catch (\Exception $e) { |
|
| 63 | - \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ |
|
| 64 | - 'exception' => $e, |
|
| 65 | - 'app' => 'core', |
|
| 66 | - ]); |
|
| 67 | - return null; |
|
| 68 | - } |
|
| 60 | + $svg->readImageBlob($content); |
|
| 61 | + $svg->setImageFormat('png32'); |
|
| 62 | + } catch (\Exception $e) { |
|
| 63 | + \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), [ |
|
| 64 | + 'exception' => $e, |
|
| 65 | + 'app' => 'core', |
|
| 66 | + ]); |
|
| 67 | + return null; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - //new image object |
|
| 71 | - $image = new \OCP\Image(); |
|
| 72 | - $image->loadFromData((string) $svg); |
|
| 73 | - //check if image object is valid |
|
| 74 | - if ($image->valid()) { |
|
| 75 | - $image->scaleDownToFit($maxX, $maxY); |
|
| 70 | + //new image object |
|
| 71 | + $image = new \OCP\Image(); |
|
| 72 | + $image->loadFromData((string) $svg); |
|
| 73 | + //check if image object is valid |
|
| 74 | + if ($image->valid()) { |
|
| 75 | + $image->scaleDownToFit($maxX, $maxY); |
|
| 76 | 76 | |
| 77 | - return $image; |
|
| 78 | - } |
|
| 79 | - return null; |
|
| 80 | - } |
|
| 77 | + return $image; |
|
| 78 | + } |
|
| 79 | + return null; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class XBitmap extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType(): string { |
|
| 30 | - return '/image\/x-xbitmap/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType(): string { |
|
| 30 | + return '/image\/x-xbitmap/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | namespace OC\Preview; |
| 24 | 24 | |
| 25 | 25 | class PNG extends Image { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType(): string { |
|
| 30 | - return '/image\/png/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType(): string { |
|
| 30 | + return '/image\/png/'; |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | |
| 24 | 24 | //.docm, .dotm, .xls(m), .xlt(m), .xla(m), .ppt(m), .pot(m), .pps(m), .ppa(m) |
| 25 | 25 | class MSOffice2003 extends Office { |
| 26 | - /** |
|
| 27 | - * {@inheritDoc} |
|
| 28 | - */ |
|
| 29 | - public function getMimeType(): string { |
|
| 30 | - return '/application\/vnd.ms-.*/'; |
|
| 31 | - } |
|
| 26 | + /** |
|
| 27 | + * {@inheritDoc} |
|
| 28 | + */ |
|
| 29 | + public function getMimeType(): string { |
|
| 30 | + return '/application\/vnd.ms-.*/'; |
|
| 31 | + } |
|
| 32 | 32 | } |