diff --git a/README.md b/README.md
index 2fa62d1..6507c0d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Camera RAW Previews
-[![Github All Releases](https://img.shields.io/github/downloads/cowai/camerarawpreviews/total.svg)](https://github.com/cowai/camerarawpreviews/releases) [![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/AriSelseng/2EUR)
+[![Github All Releases](https://img.shields.io/github/downloads/ariselseng/camerarawpreviews/total.svg)](https://github.com/cowai/camerarawpreviews/releases) [![paypal](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/AriSelseng/2EUR)
A Nextcloud/ownCloud app that provides previews for camera RAW images like .CR2, .CRW, .DNG, .MRW, .NEF, .NRW, .RW2, .SRW, .SRW, etc.
This app also gives you preview of Adobe Indesign files (.INDD).
@@ -9,6 +9,7 @@ This app also gives you preview of Adobe Indesign files (.INDD).
* Probably **memory_limit** quite high.
* **imagick** or **gd** module. If imagick is available, it will use that for performance.
* For files with a TIFF preview (at least some DNG files), **imagick** is required
+* Perl installed. A deprecated fallback is used now that will be removed in a future version.
## Installation
Install in Nextcloud App store.
diff --git a/appinfo/app.php b/appinfo/app.php
index 25b9a9d..ab89108 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -1,46 +1,4 @@
getContainer();
-$eventDispatcher = \OC::$server->getEventDispatcher();
-$eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
- script('camerarawpreviews', 'register-viewer'); // adds js/script.js
-});
-$mimeTypeDetector = \OC::$server->getMimeTypeDetector();
-$mimes = $mimeTypeDetector->getAllMappings();
-$mimes_to_detect = [
- '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'],
-];
-
-$mimeTypeDetector->registerTypeArray($mimes_to_detect);
-
-$previewManager = $container->getServer()->query('PreviewManager');
-
-$previewManager->registerProvider('/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/', function () {
- return new \OCA\CameraRawPreviews\RawPreview;
-});
+$app = new \OCA\CameraRawPreviews\AppInfo\Application;
+$app->register();
\ No newline at end of file
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 090b941..fede994 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,17 +5,17 @@
Camera RAW Previews
Preview and show camera RAW files in Nextcloud/ownCloud
- 0.7.0
+ 0.7.1
agpl
Ari Selseng
CameraRawPreviews
- https://raw.githubusercontent.com/cowai/camerarawpreviews/master/screenshots/screenshot1.png
+ https://raw.githubusercontent.com/ariselseng/camerarawpreviews/master/screenshots/screenshot1.png
files
multimedia
- https://github.com/cowai/camerarawpreviews/issues
+ https://github.com/ariselseng/camerarawpreviews/issues
-
+
diff --git a/composer.json b/composer.json
index 8f4cdf9..6329ea9 100644
--- a/composer.json
+++ b/composer.json
@@ -1,9 +1,9 @@
{
- "name": "cowai/camerarawpreviews",
+ "name": "ariselseng/camerarawpreviews",
"type": "project",
"require": {
"jmoati/exiftool-bin": "^11.26",
- "intervention/image": "^2.4.2"
+ "intervention/image": "^2.5.0"
},
"license": "agpl",
"authors": [
diff --git a/composer.lock b/composer.lock
index e55bb1f..9f094f5 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,37 +4,41 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "9a03ee399e71ba8995f9889628453612",
+ "content-hash": "25243bcdcf186e6667f6aae1fd54f573",
"packages": [
{
"name": "guzzlehttp/psr7",
- "version": "1.5.2",
+ "version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
- "reference": "9f83dded91781a01c63574e387eaa769be769115"
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115",
- "reference": "9f83dded91781a01c63574e387eaa769be769115",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a",
+ "reference": "239400de7a173fe9901b9ac7c06497751f00727a",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
- "ralouphie/getallheaders": "^2.0.5"
+ "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
+ "ext-zlib": "*",
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
},
+ "suggest": {
+ "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses"
+ },
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.5-dev"
+ "dev-master": "1.6-dev"
}
},
"autoload": {
@@ -71,20 +75,20 @@
"uri",
"url"
],
- "time": "2018-12-04T20:46:45+00:00"
+ "time": "2019-07-01T23:21:34+00:00"
},
{
"name": "intervention/image",
- "version": "2.4.2",
+ "version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
- "reference": "e82d274f786e3d4b866a59b173f42e716f0783eb"
+ "reference": "39eaef720d082ecc54c64bf54541c55f10db546d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/Intervention/image/zipball/e82d274f786e3d4b866a59b173f42e716f0783eb",
- "reference": "e82d274f786e3d4b866a59b173f42e716f0783eb",
+ "url": "https://api.github.com/repos/Intervention/image/zipball/39eaef720d082ecc54c64bf54541c55f10db546d",
+ "reference": "39eaef720d082ecc54c64bf54541c55f10db546d",
"shasum": ""
},
"require": {
@@ -141,7 +145,7 @@
"thumbnail",
"watermark"
],
- "time": "2018-05-29T14:19:03+00:00"
+ "time": "2019-06-24T14:06:31+00:00"
},
{
"name": "jmoati/exiftool-bin",
@@ -222,24 +226,24 @@
},
{
"name": "ralouphie/getallheaders",
- "version": "2.0.5",
+ "version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
- "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa"
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
- "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
- "php": ">=5.3"
+ "php": ">=5.6"
},
"require-dev": {
- "phpunit/phpunit": "~3.7.0",
- "satooshi/php-coveralls": ">=1.0"
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
@@ -258,7 +262,7 @@
}
],
"description": "A polyfill for getallheaders.",
- "time": "2016-02-11T07:05:27+00:00"
+ "time": "2019-03-08T08:55:37+00:00"
}
],
"packages-dev": [],
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
new file mode 100644
index 0000000..35a3373
--- /dev/null
+++ b/lib/AppInfo/Application.php
@@ -0,0 +1,70 @@
+appName = 'camerarawpreviews';
+
+ parent::__construct($this->appName);
+ }
+
+ public function register()
+ {
+ $this->registerScripts();
+ $container = $this->getContainer();
+ $mimeTypeDetector = \OC::$server->getMimeTypeDetector();
+ $mimes_to_detect = [
+ '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'],
+ ];
+
+ $mimeTypeDetector->registerTypeArray($mimes_to_detect);
+
+ $previewManager = $container->getServer()->query('PreviewManager');
+ $appName = $this->appName;
+ $previewManager->registerProvider('/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/', function () use($appName) {
+ return new RawPreview($this->getContainer()->getServer()->getLogger(), $appName);
+ });
+
+ }
+
+ private function registerScripts()
+ {
+ $eventDispatcher = \OC::$server->getEventDispatcher();
+ $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function () {
+ script($this->appName, 'register-viewer'); // adds js/script.js
+ });
+ }
+
+}
diff --git a/lib/RawPreview.php b/lib/RawPreview.php
index a15cd1f..76f4eb2 100644
--- a/lib/RawPreview.php
+++ b/lib/RawPreview.php
@@ -1,4 +1,5 @@
logger = $logger;
+ $this->appName = $appName;
+
if (extension_loaded('imagick') && count(\Imagick::queryformats('JPEG')) > 0) {
$this->driver = 'imagick';
}
Image::configure(array('driver' => $this->driver));
- $perl_bin = \OC_Helper::findBinaryPath('perl');
- if (empty($perl_bin)) {
- $perl_bin = exec("command -v perl");
- }
- if (empty($perl_bin)) {
- //fallback to static vendored perl
- if (php_uname("s") === "Linux" && substr(php_uname("m"), 0, 3) === 'x86') {
- $perl_bin = realpath(__DIR__ . '/../bin/staticperl');
- if (!is_executable($perl_bin) && is_writable($perl_bin)) {
- chmod($perl_bin, 0744);
- }
- } else {
- $perl_bin = "perl";
- }
+ try {
+ $perlBin = $this->getPerlExecuteable();
+ $this->converter = $perlBin . ' ' . realpath(__DIR__ . '/../vendor/jmoati/exiftool-bin/exiftool');
+ $this->perlFound = true;
+ } catch (\Exception $e) {
+ $this->logger->logException($e, ['app' => $this->appName]);
}
-
- $this->converter = $perl_bin . ' ' . realpath(__DIR__ . '/../vendor/jmoati/exiftool-bin/exiftool');
}
- /**
- * {@inheritDoc}
- */
+
public function getMimeType()
{
return '/^((image\/x-dcraw)|(image\/x-indesign))(;+.*)*$/';
@@ -61,8 +57,7 @@ protected function getBestPreviewTag($tmpPath)
return 'PreviewImage';
} else if (isset($previewData[0]['OtherImage'])) {
return 'OtherImage';
- }
- else if (isset($previewData[0]['ThumbnailImage'])) {
+ } else if (isset($previewData[0]['ThumbnailImage'])) {
return 'ThumbnailImage';
} else if (isset($previewData[0]['PreviewTIFF'])) {
if ($this->driver === 'imagick') {
@@ -81,6 +76,41 @@ protected function getBestPreviewTag($tmpPath)
}
}
+ private function getPerlExecuteable()
+ {
+ $perlBin = \OC_Helper::findBinaryPath('perl');
+ if (!is_null($perlBin)) {
+ return $perlBin;
+ }
+
+ $perlBin = exec("command -v perl");
+ if (!empty($perlBin)) {
+ return $perlBin;
+ }
+
+ //fallback to static vendored perl
+ if (php_uname("s") === "Linux" && substr(php_uname("m"), 0, 3) === 'x86') {
+ $perlBin = realpath(__DIR__ . '/../bin/staticperl');
+ $fallback_is_executable = is_executable($perlBin);
+
+ if (!$fallback_is_executable && is_writable($perlBin)) {
+ $fallback_is_executable = chmod($perlBin, 0744);
+ }
+
+ if ($fallback_is_executable) {
+ $this->logger->warning('You do not have perl globally installed. Using a deprecated built in perl.', ['app' => $this->appName]);
+ } else {
+ $perlBin = null;
+ }
+ }
+
+ if (!empty($perlBin)) {
+ return $perlBin;
+ }
+
+ throw new \Exception('No perl executeable found. Camera Raw Previews app will not work.');
+ }
+
protected function getResizedPreview($tmpPath, $maxX, $maxY)
{
$previewTag = $this->getBestPreviewTag($tmpPath);
@@ -108,7 +138,7 @@ protected function getResizedPreview($tmpPath, $maxX, $maxY)
public function isAvailable(FileInfo $file)
{
- return $file->getSize() > 0;
+ return $this->perlFound && $file->getSize() > 0;
}
}