diff --git a/config/config.sample.php b/config/config.sample.php index 71d22fbe2b..c0121a8d56 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -989,7 +989,6 @@ $CONFIG = [ * - OC\Preview\MSOffice2003 * - OC\Preview\MSOffice2007 * - OC\Preview\MSOfficeDoc - * - OC\Preview\OpenDocument * - OC\Preview\PDF * - OC\Preview\Photoshop * - OC\Preview\Postscript @@ -1018,6 +1017,8 @@ $CONFIG = [ * - OC\Preview\PNG * - OC\Preview\TXT * - OC\Preview\XBitmap + * - OC\Preview\OpenDocument + * - OC\Preview\Krita */ 'enabledPreviewProviders' => [ 'OC\Preview\PNG', @@ -1028,7 +1029,9 @@ $CONFIG = [ 'OC\Preview\XBitmap', 'OC\Preview\MP3', 'OC\Preview\TXT', - 'OC\Preview\MarkDown' + 'OC\Preview\MarkDown', + 'OC\Preview\OpenDocument', + 'OC\Preview\Krita', ], /** diff --git a/lib/private/Preview/Bundled.php b/lib/private/Preview/Bundled.php index 6f3d811ca6..afd286d895 100644 --- a/lib/private/Preview/Bundled.php +++ b/lib/private/Preview/Bundled.php @@ -23,10 +23,9 @@ namespace OC\Preview; +use OC\Archive\ZIP; use OCP\Files\File; -use OCP\Files\NotPermittedException; use OCP\IImage; -use OCP\Lock\LockedException; /** * Extracts a preview from files that embed them in an ZIP archive @@ -39,10 +38,9 @@ abstract class Bundled extends ProviderV2 { try { $content = $file->fopen('r'); - $content = stream_get_contents($content); file_put_contents($sourceTmp, $content); - $zip = new \OC\Archive\ZIP($sourceTmp); + $zip = new ZIP($sourceTmp); $zip->extractFile($path, $targetTmp); $image = new \OC_Image(); diff --git a/lib/private/Preview/Krita.php b/lib/private/Preview/Krita.php new file mode 100644 index 0000000000..39449145a1 --- /dev/null +++ b/lib/private/Preview/Krita.php @@ -0,0 +1,52 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OC\Preview; + +use OCP\Files\File; +use OCP\IImage; + +class Krita extends Bundled { + /** + * {@inheritDoc} + */ + public function getMimeType(): string { + return '/application\/x-krita/'; + } + + + /** + * @inheritDoc + */ + public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage { + $image = $this->extractThumbnail($file, 'mergedimage.png'); + if ($image->valid()) { + return $image; + } + $image = $this->extractThumbnail($file, 'preview.png'); + if ($image->valid()) { + return $image; + } + return null; + } +} diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index ab20ccdfbb..adfc04199e 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -293,7 +293,8 @@ class PreviewManager implements IPreview { Preview\GIF::class, Preview\BMP::class, Preview\HEIC::class, - Preview\XBitmap::class + Preview\XBitmap::class, + Preview\Krita::class, ]; $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', array_merge([ @@ -340,6 +341,7 @@ class PreviewManager implements IPreview { $this->registerCoreProvider(Preview\GIF::class, '/image\/gif/'); $this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/'); $this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/'); + $this->registerCoreProvider(Preview\Krita::class, '/application\/x-krita/'); $this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/'); $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');