diff options
Diffstat (limited to 'lib/private/PreviewManager.php')
-rw-r--r-- | lib/private/PreviewManager.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 367f0c1c057..dd6b6ba8ee1 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -33,6 +33,7 @@ namespace OC; use OC\AppFramework\Bootstrap\Coordinator; use OC\Preview\Generator; use OC\Preview\GeneratorHelper; +use OC\Preview\IMagickSupport; use OCP\AppFramework\QueryException; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\File; @@ -73,6 +74,7 @@ class PreviewManager implements IPreview { private array $loadedBootstrapProviders = []; private IServerContainer $container; private IBinaryFinder $binaryFinder; + private IMagickSupport $imagickSupport; public function __construct( IConfig $config, @@ -84,7 +86,8 @@ class PreviewManager implements IPreview { ?string $userId, Coordinator $bootstrapCoordinator, IServerContainer $container, - IBinaryFinder $binaryFinder + IBinaryFinder $binaryFinder, + IMagickSupport $imagickSupport ) { $this->config = $config; $this->rootFolder = $rootFolder; @@ -96,6 +99,7 @@ class PreviewManager implements IPreview { $this->bootstrapCoordinator = $bootstrapCoordinator; $this->container = $container; $this->binaryFinder = $binaryFinder; + $this->imagickSupport = $imagickSupport; } /** @@ -368,9 +372,7 @@ class PreviewManager implements IPreview { $this->registerCoreProvider(Preview\Imaginary::class, Preview\Imaginary::supportedMimeTypes()); // SVG, Office and Bitmap require imagick - if (extension_loaded('imagick')) { - $checkImagick = new \Imagick(); - + if ($this->imagickSupport->hasExtension()) { $imagickProviders = [ 'SVG' => ['mimetype' => '/image\/svg\+xml/', 'class' => Preview\SVG::class], 'TIFF' => ['mimetype' => '/image\/tiff/', 'class' => Preview\TIFF::class], @@ -390,12 +392,12 @@ class PreviewManager implements IPreview { continue; } - if (count($checkImagick->queryFormats($queryFormat)) === 1) { + if ($this->imagickSupport->supportsFormat($queryFormat)) { $this->registerCoreProvider($class, $provider['mimetype']); } } - if (count($checkImagick->queryFormats('PDF')) === 1) { + if ($this->imagickSupport->supportsFormat('PDF')) { // Office requires openoffice or libreoffice $officeBinary = $this->config->getSystemValue('preview_libreoffice_path', null); if (!is_string($officeBinary)) { |