Skip to content

Commit

Permalink
More formats added. Correct mimetypes to get open gallery to work.
Browse files Browse the repository at this point in the history
Users need to rescan files to get the new mimetypes.
  • Loading branch information
ariselseng committed Oct 15, 2018
1 parent a369d45 commit 6902c7c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
40 changes: 28 additions & 12 deletions appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,37 @@

$mimes = $mimeTypeDetector->getAllMappings();
$mimes_to_detect = [
'crw' => 'image/x-canon-crw',
'indd' => 'image/x-indesign',
'mrw' => 'image/x-minolta-mrw',
'nrw' => 'image/x-raw-nikon',
'rw2' => 'image/x-panasonic-rw2',
'srw' => 'image/x-samsung-srw'
'indd' => ['image/x-indesign'],
'3fr' => ['image/x-dcraw'],
'arw' => ['image/x-dcraw'],
'cr2' => ['image/x-dcraw'],
'cr3' => ['image/x-dcraw'],
'crw' => ['image/x-dcraw'],
'dng' => ['image/x-dcraw'],
'erf' => ['image/x-dcraw'],
'fff' => ['image/x-dcraw'],
'iiq' => ['image/x-dcraw'],
'kdc' => ['image/x-dcraw'],
'mrw' => ['image/x-dcraw'],
'nef' => ['image/x-dcraw'],
'nrw' => ['image/x-dcraw'],
'orf' => ['image/x-dcraw'],
'ori' => ['image/x-dcraw'],
'pef' => ['image/x-dcraw'],
'raf' => ['image/x-dcraw'],
'rw2' => ['image/x-dcraw'],
'rwl' => ['image/x-dcraw'],
'sr2' => ['image/x-dcraw'],
'srf' => ['image/x-dcraw'],
'srw' => ['image/x-dcraw'],
'tif' => ['image/x-dcraw'],
'x3f' => ['image/x-dcraw'],
];
foreach ($mimes_to_detect as $key => $mime) {
if (!isset($mimes[$key])) {
$mimeTypeDetector->registerType($key, $mime);
}
}

$mimeTypeDetector->registerTypeArray($mimes_to_detect);

$previewManager = $container->getServer()->query('PreviewManager');

$previewManager->registerProvider('/^((image\/x-dcraw)|(image\/x-canon-crw)|(image\/x-minolta-mrw)|(image\/x-panasonic-rw2)|(image\/x-samsung-srw)|(image\/x-raw-nikon)|(image\/x-indesign))(;+.*)*$/', function () {
$previewManager->registerProvider('/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/', function () {
return new \OCA\CameraRawPreviews\RawPreview;
});
15 changes: 13 additions & 2 deletions lib/RawPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct()
*/
public function getMimeType()
{
return '/^((image\/x-dcraw)|(image\/x-canon-crw)|(image\/x-minolta-mrw)|(image\/x-panasonic-rw2)|(image\/x-samsung-srw)|(image\/x-raw-nikon)|(image\/x-indesign))(;+.*)*$/';
return '/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/';
}

protected function getBestPreviewTag($tmpPath)
Expand All @@ -59,12 +59,23 @@ protected function getBestPreviewTag($tmpPath)
return 'PageImage';
} else if (isset($previewData[0]['PreviewImage'])) {
return 'PreviewImage';
} else if (isset($previewData[0]['PreviewTIFF']) || isset($previewData[0]['ThumbnailTIFF'])) {
} else if (isset($previewData[0]['OtherImage'])) {
return 'OtherImage';
}
else if (isset($previewData[0]['ThumbnailImage'])) {
return 'ThumbnailImage';
} else if (isset($previewData[0]['PreviewTIFF'])) {
if ($this->driver === 'imagick') {
return 'PreviewTIFF';
} else {
throw new \Exception('Needs imagick to extract TIFF previews');
}
} else if (isset($previewData[0]['ThumbnailTIFF'])) {
if ($this->driver === 'imagick') {
return 'ThumbnailTIFF';
} else {
throw new \Exception('Needs imagick to extract TIFF previews');
}
} else {
throw new \Exception('Unable to find preview data');
}
Expand Down

0 comments on commit 6902c7c

Please sign in to comment.