From d47b84be67242960f6af5e8d16ea140e62a0933b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Fri, 22 Jan 2021 10:35:37 +0100 Subject: [PATCH] Add SGI and TGA preview support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- lib/private/Preview/SGI.php | 33 ++++++++++++++++++++++ lib/private/Preview/TGA.php | 33 ++++++++++++++++++++++ lib/private/PreviewManager.php | 4 ++- resources/config/mimetypealiases.dist.json | 4 ++- resources/config/mimetypemapping.dist.json | 2 ++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 lib/private/Preview/SGI.php create mode 100644 lib/private/Preview/TGA.php diff --git a/lib/private/Preview/SGI.php b/lib/private/Preview/SGI.php new file mode 100644 index 0000000000..2e19836267 --- /dev/null +++ b/lib/private/Preview/SGI.php @@ -0,0 +1,33 @@ + + * + * @author John Molakvoæ + * + * @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; + +//.sgi +class SGI extends Bitmap { + /** + * {@inheritDoc} + */ + public function getMimeType(): string { + return '/image\/sgi/'; + } +} diff --git a/lib/private/Preview/TGA.php b/lib/private/Preview/TGA.php new file mode 100644 index 0000000000..d29cb3e2c1 --- /dev/null +++ b/lib/private/Preview/TGA.php @@ -0,0 +1,33 @@ + + * + * @author John Molakvoæ + * + * @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; + +//.tga +class TGA extends Bitmap { + /** + * {@inheritDoc} + */ + public function getMimeType(): string { + return '/image\/t(ar)?ga/'; + } +} diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 1d65da8ca5..d6dc700e4a 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -4,7 +4,7 @@ * * @author Christoph Wurst * @author Joas Schilling - * @author John Molakvoæ (skjnldsv) + * @author John Molakvoæ * @author Julius Härtl * @author Morris Jobke * @author Olivier Paroz @@ -379,6 +379,8 @@ class PreviewManager implements IPreview { 'EPS' => ['mimetype' => '/application\/postscript/', 'class' => Preview\Postscript::class], 'TTF' => ['mimetype' => '/application\/(?:font-sfnt|x-font$)/', 'class' => Preview\Font::class], 'HEIC' => ['mimetype' => '/image\/hei(f|c)/', 'class' => Preview\HEIC::class], + 'TGA' => ['mimetype' => '/image\/t(ar)?ga/', 'class' => Preview\TGA::class], + 'SGI' => ['mimetype' => '/image\/sgi/', 'class' => Preview\SGI::class], ]; foreach ($imagickProviders as $queryFormat => $provider) { diff --git a/resources/config/mimetypealiases.dist.json b/resources/config/mimetypealiases.dist.json index 332daea197..d02027619d 100644 --- a/resources/config/mimetypealiases.dist.json +++ b/resources/config/mimetypealiases.dist.json @@ -104,6 +104,8 @@ "application/internet-shortcut": "link", "application/km": "mindmap", "application/x-freemind": "mindmap", - "application/vnd.xmind.workbook": "mindmap" + "application/vnd.xmind.workbook": "mindmap", + "image/targa": "image/tga", + "image/targa": "image/tga" } diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index 33e4ac016f..b38046aef3 100644 --- a/resources/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -165,6 +165,7 @@ "rw2": ["image/x-dcraw"], "schema": ["text/plain"], "sgf": ["application/sgf"], + "sgi": ["image/sgi"], "sh-lib": ["text/x-shellscript"], "sh": ["text/x-shellscript"], "srf": ["image/x-dcraw"], @@ -177,6 +178,7 @@ "tbz2": ["application/x-bzip2"], "tcx": ["application/vnd.garmin.tcx+xml"], "tex": ["application/x-tex"], + "tga": ["image/tga"], "tgz": ["application/x-compressed"], "tiff": ["image/tiff"], "tif": ["image/tiff"],