Skip to content

Commit e0f0e6e

Browse files
Merge pull request #25268 from nextcloud/enh/previews/sgi-tga
Add SGI and TGA preview support
2 parents 75300cb + 0bc9e3c commit e0f0e6e

File tree

8 files changed

+79
-3
lines changed

8 files changed

+79
-3
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ Simon Birnbach <simon@simon-birnbach.de>
358358
Simon Könnecke <simonkoennecke@gmail.com>
359359
Simon Whittaker <simon@swbh.net>
360360
Sjors van der Pluijm <sjors@desjors.nl> Sjors van der Pluijm <sjors@youngguns.nl>
361-
John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> John Molakvoæ <skjnldsv@users.noreply.github.com>
361+
John Molakvoæ <skjnldsv@protonmail.com> John Molakvoæ <skjnldsv@users.noreply.github.com>
362+
John Molakvoæ <skjnldsv@protonmail.com> John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
362363
st3so <st3so@server.fake>
363364
Stefan <mu.stefan@googlemail.com>
364365
Stefan Göckeritz <admin@s-goecker.de>

lib/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,9 +1247,11 @@
12471247
'OC\\Preview\\Provider' => $baseDir . '/lib/private/Preview/Provider.php',
12481248
'OC\\Preview\\ProviderV1Adapter' => $baseDir . '/lib/private/Preview/ProviderV1Adapter.php',
12491249
'OC\\Preview\\ProviderV2' => $baseDir . '/lib/private/Preview/ProviderV2.php',
1250+
'OC\\Preview\\SGI' => $baseDir . '/lib/private/Preview/SGI.php',
12501251
'OC\\Preview\\SVG' => $baseDir . '/lib/private/Preview/SVG.php',
12511252
'OC\\Preview\\StarOffice' => $baseDir . '/lib/private/Preview/StarOffice.php',
12521253
'OC\\Preview\\Storage\\Root' => $baseDir . '/lib/private/Preview/Storage/Root.php',
1254+
'OC\\Preview\\TGA' => $baseDir . '/lib/private/Preview/TGA.php',
12531255
'OC\\Preview\\TIFF' => $baseDir . '/lib/private/Preview/TIFF.php',
12541256
'OC\\Preview\\TXT' => $baseDir . '/lib/private/Preview/TXT.php',
12551257
'OC\\Preview\\Watcher' => $baseDir . '/lib/private/Preview/Watcher.php',

lib/composer/composer/autoload_static.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,9 +1276,11 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
12761276
'OC\\Preview\\Provider' => __DIR__ . '/../../..' . '/lib/private/Preview/Provider.php',
12771277
'OC\\Preview\\ProviderV1Adapter' => __DIR__ . '/../../..' . '/lib/private/Preview/ProviderV1Adapter.php',
12781278
'OC\\Preview\\ProviderV2' => __DIR__ . '/../../..' . '/lib/private/Preview/ProviderV2.php',
1279+
'OC\\Preview\\SGI' => __DIR__ . '/../../..' . '/lib/private/Preview/SGI.php',
12791280
'OC\\Preview\\SVG' => __DIR__ . '/../../..' . '/lib/private/Preview/SVG.php',
12801281
'OC\\Preview\\StarOffice' => __DIR__ . '/../../..' . '/lib/private/Preview/StarOffice.php',
12811282
'OC\\Preview\\Storage\\Root' => __DIR__ . '/../../..' . '/lib/private/Preview/Storage/Root.php',
1283+
'OC\\Preview\\TGA' => __DIR__ . '/../../..' . '/lib/private/Preview/TGA.php',
12821284
'OC\\Preview\\TIFF' => __DIR__ . '/../../..' . '/lib/private/Preview/TIFF.php',
12831285
'OC\\Preview\\TXT' => __DIR__ . '/../../..' . '/lib/private/Preview/TXT.php',
12841286
'OC\\Preview\\Watcher' => __DIR__ . '/../../..' . '/lib/private/Preview/Watcher.php',

lib/private/Preview/SGI.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @copyright 2021 John Molakvoæ <skjnldsv@protonmail.com>
4+
*
5+
* @author John Molakvoæ <skjnldsv@protonmail.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
namespace OC\Preview;
24+
25+
//.sgi
26+
class SGI extends Bitmap {
27+
/**
28+
* {@inheritDoc}
29+
*/
30+
public function getMimeType(): string {
31+
return '/image\/sgi/';
32+
}
33+
}

lib/private/Preview/TGA.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* @copyright 2021 John Molakvoæ <skjnldsv@protonmail.com>
4+
*
5+
* @author John Molakvoæ <skjnldsv@protonmail.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
namespace OC\Preview;
24+
25+
//.tga
26+
class TGA extends Bitmap {
27+
/**
28+
* {@inheritDoc}
29+
*/
30+
public function getMimeType(): string {
31+
return '/image\/t(ar)?ga/';
32+
}
33+
}

lib/private/PreviewManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
66
* @author Joas Schilling <coding@schilljs.com>
7-
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
7+
* @author John Molakvoæ <skjnldsv@protonmail.com>
88
* @author Julius Härtl <jus@bitgrid.net>
99
* @author Morris Jobke <hey@morrisjobke.de>
1010
* @author Olivier Paroz <github@oparoz.com>
@@ -379,6 +379,8 @@ protected function registerCoreProviders() {
379379
'EPS' => ['mimetype' => '/application\/postscript/', 'class' => Preview\Postscript::class],
380380
'TTF' => ['mimetype' => '/application\/(?:font-sfnt|x-font$)/', 'class' => Preview\Font::class],
381381
'HEIC' => ['mimetype' => '/image\/hei(f|c)/', 'class' => Preview\HEIC::class],
382+
'TGA' => ['mimetype' => '/image\/t(ar)?ga/', 'class' => Preview\TGA::class],
383+
'SGI' => ['mimetype' => '/image\/sgi/', 'class' => Preview\SGI::class],
382384
];
383385

384386
foreach ($imagickProviders as $queryFormat => $provider) {

resources/config/mimetypealiases.dist.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"application/internet-shortcut": "link",
105105
"application/km": "mindmap",
106106
"application/x-freemind": "mindmap",
107-
"application/vnd.xmind.workbook": "mindmap"
107+
"application/vnd.xmind.workbook": "mindmap",
108+
"image/targa": "image/tga"
108109
}
109110

resources/config/mimetypemapping.dist.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
"rw2": ["image/x-dcraw"],
166166
"schema": ["text/plain"],
167167
"sgf": ["application/sgf"],
168+
"sgi": ["image/sgi"],
168169
"sh-lib": ["text/x-shellscript"],
169170
"sh": ["text/x-shellscript"],
170171
"srf": ["image/x-dcraw"],
@@ -177,6 +178,7 @@
177178
"tbz2": ["application/x-bzip2"],
178179
"tcx": ["application/vnd.garmin.tcx+xml"],
179180
"tex": ["application/x-tex"],
181+
"tga": ["image/tga"],
180182
"tgz": ["application/x-compressed"],
181183
"tiff": ["image/tiff"],
182184
"tif": ["image/tiff"],

0 commit comments

Comments
 (0)