mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
Merge 150dc960c0 into d09b8c99de
This commit is contained in:
commit
f83a6ceb73
1 changed files with 8 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ use OCP\FilesMetadata\Event\MetadataBackgroundEvent;
|
|||
use OCP\FilesMetadata\Event\MetadataLiveEvent;
|
||||
use OCP\IPreview;
|
||||
use OCP\Lock\LockedException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Generate a Blurhash string as metadata when image file is uploaded/edited.
|
||||
|
|
@ -33,6 +34,7 @@ class GenerateBlurhashMetadata implements IEventListener {
|
|||
|
||||
public function __construct(
|
||||
private IPreview $preview,
|
||||
private readonly LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +84,8 @@ class GenerateBlurhashMetadata implements IEventListener {
|
|||
|
||||
$metadata->setString('blurhash', $this->generateBlurHash($image))
|
||||
->setEtag('blurhash', $currentEtag);
|
||||
|
||||
@imagedestroy($image);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,6 +97,10 @@ class GenerateBlurhashMetadata implements IEventListener {
|
|||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
|
||||
if (max($width, $height) > 64) {
|
||||
$this->logger->notice('blurhash should be generated using 64x64 preview');
|
||||
}
|
||||
|
||||
$pixels = [];
|
||||
for ($y = 0; $y < $height; ++$y) {
|
||||
$row = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue