mirror of
https://github.com/nextcloud/server.git
synced 2026-06-17 20:50:05 -04:00
Merge pull request #46954 from nextcloud/backport/46864/stable29
This commit is contained in:
commit
bf526d8f95
1 changed files with 4 additions and 19 deletions
|
|
@ -32,12 +32,10 @@ use OCP\EventDispatcher\Event;
|
|||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Files\GenericFileException;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\NotPermittedException;
|
||||
use OCP\FilesMetadata\AMetadataEvent;
|
||||
use OCP\FilesMetadata\Event\MetadataBackgroundEvent;
|
||||
use OCP\FilesMetadata\Event\MetadataLiveEvent;
|
||||
use OCP\IPreview;
|
||||
use OCP\Lock\LockedException;
|
||||
|
||||
/**
|
||||
|
|
@ -51,11 +49,6 @@ class GenerateBlurhashMetadata implements IEventListener {
|
|||
private const COMPONENTS_X = 4;
|
||||
private const COMPONENTS_Y = 3;
|
||||
|
||||
public function __construct(
|
||||
private IPreview $preview,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotPermittedException
|
||||
* @throws GenericFileException
|
||||
|
|
@ -84,20 +77,12 @@ class GenerateBlurhashMetadata implements IEventListener {
|
|||
return;
|
||||
}
|
||||
|
||||
$image = false;
|
||||
try {
|
||||
// using preview image to generate the blurhash
|
||||
$preview = $this->preview->getPreview($file, 256, 256);
|
||||
$image = @imagecreatefromstring($preview->getContent());
|
||||
} catch (NotFoundException $e) {
|
||||
// https://github.com/nextcloud/server/blob/9d70fd3e64b60a316a03fb2b237891380c310c58/lib/private/legacy/OC_Image.php#L668
|
||||
// The preview system can fail on huge picture, in that case we use our own image resizer.
|
||||
if (str_starts_with($file->getMimetype(), 'image/')) {
|
||||
$image = $this->resizedImageFromFile($file);
|
||||
}
|
||||
if (!str_starts_with($file->getMimetype(), 'image/')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($image === false) {
|
||||
$image = $this->resizedImageFromFile($file);
|
||||
if (!$image) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue