From 3ca2e2d0eb17b4c7a9bc4addfe209e671ada7a61 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:41:00 +0200 Subject: [PATCH 01/15] Create AVIF.php Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/Preview/AVIF.php | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 lib/private/Preview/AVIF.php diff --git a/lib/private/Preview/AVIF.php b/lib/private/Preview/AVIF.php new file mode 100644 index 0000000000000..1e3834bf3964b --- /dev/null +++ b/lib/private/Preview/AVIF.php @@ -0,0 +1,41 @@ + + * + * @author Roeland Jago Douma + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OC\Preview; + +use OCP\Files\FileInfo; + +class AVIF extends Image { + /** + * {@inheritDoc} + */ + public function getMimeType(): string { + return '/image\/avif/'; + } + + public function isAvailable(FileInfo $file): bool { + return (bool)(imagetypes() & IMG_AVIF); + } +} From e4f0d9c78bde5c5a31972f3d96d642009eacf3da Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 20:52:33 +0200 Subject: [PATCH 02/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/PreviewManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 3af6848686ee7..c15e437c5c316 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -314,6 +314,7 @@ protected function getEnabledDefaultProvider() { Preview\XBitmap::class, Preview\Krita::class, Preview\WebP::class, + Preview\AVIF::class, ]; $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', array_merge([ @@ -361,6 +362,7 @@ protected function registerCoreProviders() { $this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/'); $this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/'); $this->registerCoreProvider(Preview\WebP::class, '/image\/webp/'); + $this->registerCoreProvider(Preview\AVIF::class, '/image\/avif/'); $this->registerCoreProvider(Preview\Krita::class, '/application\/x-krita/'); $this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/'); $this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/'); From 4068ca31e77489eb75c25b012ff7d16545749a29 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:00:52 +0200 Subject: [PATCH 03/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index aac0c49673400..228ad7709cab2 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -714,6 +714,20 @@ public function loadFromFile($imagePath = false) { $this->logger->debug('OC_Image->loadFromFile, WBMP images not supported: ' . $imagePath, ['app' => 'core']); } break; + case IMAGETYPE_AVIF: + if (imagetypes() & IMG_AVIF) { + if (!$this->checkImageSize($imagePath)) { + return false; + } + if (getimagesize($imagePath) !== false) { + $this->resource = @imagecreatefromavif($imagePath); + } else { + $this->logger->debug('OC_Image->loadFromFile, AVIF image not valid: ' . $imagePath, ['app' => 'core']); + } + } else { + $this->logger->debug('OC_Image->loadFromFile, AVIF images not supported: ' . $imagePath, ['app' => 'core']); + } + break; case IMAGETYPE_BMP: $this->resource = imagecreatefrombmp($imagePath); break; From af2f4f6027cc1b2d7dd7c21fe303bc9ec044b892 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:04:10 +0200 Subject: [PATCH 04/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/composer/composer/autoload_static.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index f9164a13aa3f4..5a2be04ada7d9 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1539,6 +1539,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Preview\\Watcher' => __DIR__ . '/../../..' . '/lib/private/Preview/Watcher.php', 'OC\\Preview\\WatcherConnector' => __DIR__ . '/../../..' . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\WebP' => __DIR__ . '/../../..' . '/lib/private/Preview/WebP.php', + 'OC\\Preview\\AVIF' => __DIR__ . '/../../..' . '/lib/private/Preview/AVIF.php', 'OC\\Preview\\XBitmap' => __DIR__ . '/../../..' . '/lib/private/Preview/XBitmap.php', 'OC\\Profile\\Actions\\EmailAction' => __DIR__ . '/../../..' . '/lib/private/Profile/Actions/EmailAction.php', 'OC\\Profile\\Actions\\FediverseAction' => __DIR__ . '/../../..' . '/lib/private/Profile/Actions/FediverseAction.php', From ddab01cfd869dabb25d5a2f787316463df80afa4 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:06:36 +0200 Subject: [PATCH 05/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/composer/composer/autoload_classmap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 007b19692c56a..a2f404ff76572 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1506,6 +1506,7 @@ 'OC\\Preview\\Watcher' => $baseDir . '/lib/private/Preview/Watcher.php', 'OC\\Preview\\WatcherConnector' => $baseDir . '/lib/private/Preview/WatcherConnector.php', 'OC\\Preview\\WebP' => $baseDir . '/lib/private/Preview/WebP.php', + 'OC\\Preview\\AVIF' => $baseDir . '/lib/private/Preview/AVIF.php', 'OC\\Preview\\XBitmap' => $baseDir . '/lib/private/Preview/XBitmap.php', 'OC\\Profile\\Actions\\EmailAction' => $baseDir . '/lib/private/Profile/Actions/EmailAction.php', 'OC\\Profile\\Actions\\FediverseAction' => $baseDir . '/lib/private/Profile/Actions/FediverseAction.php', From aa3fb33142b2ddcdb6e737bcd05a34f689ee8843 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:08:45 +0200 Subject: [PATCH 06/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- resources/config/mimetypemapping.dist.json | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index 7b631466972fd..fd70bd4f02b2d 100644 --- a/resources/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -207,6 +207,7 @@ "webloc": ["application/internet-shortcut"], "webm": ["video/webm"], "webp": ["image/webp"], + "avif": ["image/avif"], "wmv": ["video/x-ms-wmv"], "woff": ["application/font-woff"], "wpd": ["application/vnd.wordperfect"], From 497a641bc41f0c0f146f96ffa78c51f531778220 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Fri, 25 Aug 2023 21:13:59 +0200 Subject: [PATCH 07/15] add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/Collaboration/Reference/LinkReferenceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/Collaboration/Reference/LinkReferenceProvider.php b/lib/private/Collaboration/Reference/LinkReferenceProvider.php index dbdab75abcb3a..af0cc9f103fea 100644 --- a/lib/private/Collaboration/Reference/LinkReferenceProvider.php +++ b/lib/private/Collaboration/Reference/LinkReferenceProvider.php @@ -51,7 +51,8 @@ class LinkReferenceProvider implements IReferenceProvider { 'image/jpeg', 'image/gif', 'image/svg+xml', - 'image/webp' + 'image/webp', + 'image/avif' ]; private IClientService $clientService; From 55d697363c75261e35f168da098fbea28a2c703b Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:25:12 +0200 Subject: [PATCH 08/15] Change mimeType for AVIF previews to JPEG Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index 228ad7709cab2..2976eef238ded 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -273,6 +273,9 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo case 'image/jpeg': $imageType = IMAGETYPE_JPEG; break; + case 'image/avif': + $imageType = IMAGETYPE_AVIF; + break; case 'image/png': $imageType = IMAGETYPE_PNG; break; @@ -363,6 +366,8 @@ public function dataMimeType(): ?string { switch ($this->mimeType) { case 'image/png': case 'image/jpeg': + case 'image/avif': + return 'image/jpeg'; case 'image/gif': return $this->mimeType; default: @@ -388,6 +393,12 @@ public function data(): ?string { $quality = $this->getJpegQuality(); $res = imagejpeg($this->resource, null, $quality); break; + case "image/avif": + /** @psalm-suppress InvalidScalarArgument */ + imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); + $quality = $this->getJpegQuality(); + $res = imagejpeg($this->resource, null, $quality); + break; case "image/gif": $res = imagegif($this->resource); break; @@ -719,11 +730,7 @@ public function loadFromFile($imagePath = false) { if (!$this->checkImageSize($imagePath)) { return false; } - if (getimagesize($imagePath) !== false) { - $this->resource = @imagecreatefromavif($imagePath); - } else { - $this->logger->debug('OC_Image->loadFromFile, AVIF image not valid: ' . $imagePath, ['app' => 'core']); - } + $this->resource = @imagecreatefromavif($imagePath); } else { $this->logger->debug('OC_Image->loadFromFile, AVIF images not supported: ' . $imagePath, ['app' => 'core']); } From 59bb8798922eee1abce46716884579978afa248f Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Sun, 10 Sep 2023 19:07:33 +0200 Subject: [PATCH 09/15] Template for AVIF as preview format removed Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index 2976eef238ded..cb21cf829b46c 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -273,9 +273,6 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo case 'image/jpeg': $imageType = IMAGETYPE_JPEG; break; - case 'image/avif': - $imageType = IMAGETYPE_AVIF; - break; case 'image/png': $imageType = IMAGETYPE_PNG; break; @@ -393,12 +390,6 @@ public function data(): ?string { $quality = $this->getJpegQuality(); $res = imagejpeg($this->resource, null, $quality); break; - case "image/avif": - /** @psalm-suppress InvalidScalarArgument */ - imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); - $quality = $this->getJpegQuality(); - $res = imagejpeg($this->resource, null, $quality); - break; case "image/gif": $res = imagegif($this->resource); break; From 276d4737db190755d67fdcaf73e3be7f871a3334 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Sun, 10 Sep 2023 23:50:19 +0200 Subject: [PATCH 10/15] Experimental support for WebP and AVIF as a preview Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index cb21cf829b46c..f1ec037ff1cd0 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -54,6 +54,8 @@ class OC_Image implements \OCP\IImage { // Default quality for jpeg images protected const DEFAULT_JPEG_QUALITY = 80; + protected const DEFAULT_WEBP_QUALITY = 80; + protected const DEFAULT_AVIF_QUALITY = 80; /** @var false|resource|\GdImage */ protected $resource = false; // tmp resource. @@ -273,6 +275,12 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo case 'image/jpeg': $imageType = IMAGETYPE_JPEG; break; + case 'image/webp': + $imageType = IMAGETYPE_WEBP; + break; + case 'image/avif': + $imageType = IMAGETYPE_AVIF; + break; case 'image/png': $imageType = IMAGETYPE_PNG; break; @@ -297,6 +305,16 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); $retVal = imagejpeg($this->resource, $filePath, $this->getJpegQuality()); break; + case "image/webp": + /** @psalm-suppress InvalidScalarArgument */ + imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + $retVal = imagewebp($this->resource, $filePath, $this->getWebpQuality()); + break; + case "image/avif": + /** @psalm-suppress InvalidScalarArgument */ + imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + $retVal = imageavif($this->resource, $filePath, $this->getAvifQuality(), 10); + break; case IMAGETYPE_PNG: $retVal = imagepng($this->resource, $filePath); break; @@ -360,9 +378,24 @@ public function dataMimeType(): ?string { return null; } + if ($this->mimeType !== 'image/gif') { + $preview_format = $this->config->getSystemValueString('preview_format', 'jpeg'); + + switch ($preview_format) { // Change the format to the correct one + case 'webp': + return 'image/webp'; + break; + case 'avif': + return 'image/avif'; + break; + default: + } + } + switch ($this->mimeType) { case 'image/png': case 'image/jpeg': + case 'image/webp': case 'image/avif': return 'image/jpeg'; case 'image/gif': @@ -390,6 +423,16 @@ public function data(): ?string { $quality = $this->getJpegQuality(); $res = imagejpeg($this->resource, null, $quality); break; + case "image/webp": + /** @psalm-suppress InvalidScalarArgument */ + imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + $res = imagewebp($this->resource, null, $this->getWebpQuality()); + break; + case "image/avif": + /** @psalm-suppress InvalidScalarArgument */ + imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + $res = imageavif($this->resource, null, $this->getAvifQuality(), 10); + break; case "image/gif": $res = imagegif($this->resource); break; @@ -423,6 +466,24 @@ protected function getJpegQuality(): int { return min(100, max(10, (int) $quality)); } + protected function getWebpQuality(): int { + $quality = $this->config->getAppValue('preview', 'webp_quality', (string) self::DEFAULT_WEBP_QUALITY); + // TODO: remove when getAppValue is type safe + if ($quality === null) { + $quality = self::DEFAULT_WEBP_QUALITY; + } + return min(100, max(10, (int) $quality)); + } + + protected function getAvifQuality(): int { + $quality = $this->config->getAppValue('preview', 'avif_quality', (string) self::DEFAULT_AVIF_QUALITY); + // TODO: remove when getAppValue is type safe + if ($quality === null) { + $quality = self::DEFAULT_AVIF_QUALITY; + } + return min(100, max(10, (int) $quality)); + } + /** * (I'm open for suggestions on better method name ;) * Get the orientation based on EXIF data. From 0710c149808d7fa5744e0ff092179d82456262d0 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Mon, 11 Sep 2023 12:22:51 +0200 Subject: [PATCH 11/15] experimental default format for AVIF is JPEG _output() is maybe useless WebP have longer time to encode as PNG and JPEG, maybe remove it too by default for WebP. Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 44 ++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index f1ec037ff1cd0..8b5cedfcbde3a 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -279,7 +279,7 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo $imageType = IMAGETYPE_WEBP; break; case 'image/avif': - $imageType = IMAGETYPE_AVIF; + $imageType = IMAGETYPE_JPEG; break; case 'image/png': $imageType = IMAGETYPE_PNG; @@ -296,6 +296,19 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo } } + if ($this->mimeType !== 'image/gif') { + $preview_format = $this->config->getSystemValueString('preview_format', ''); + switch ($preview_format) { + case 'webp': + $imageType = IMAGETYPE_WEBP; + break; + case 'avif': + $imageType = IMAGETYPE_AVIF; + break; + default: + } + } + switch ($imageType) { case IMAGETYPE_GIF: $retVal = imagegif($this->resource, $filePath); @@ -307,7 +320,7 @@ private function _output(?string $filePath = null, ?string $mimeType = null): bo break; case "image/webp": /** @psalm-suppress InvalidScalarArgument */ - imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); $retVal = imagewebp($this->resource, $filePath, $this->getWebpQuality()); break; case "image/avif": @@ -379,15 +392,12 @@ public function dataMimeType(): ?string { } if ($this->mimeType !== 'image/gif') { - $preview_format = $this->config->getSystemValueString('preview_format', 'jpeg'); - - switch ($preview_format) { // Change the format to the correct one + $preview_format = $this->config->getSystemValueString('preview_format', ''); + switch ($preview_format) { case 'webp': return 'image/webp'; - break; case 'avif': return 'image/avif'; - break; default: } } @@ -413,7 +423,23 @@ public function data(): ?string { return null; } ob_start(); - switch ($this->mimeType) { + $imageType = $this->imageType; + if ($imageType == 'image/avif') { + $imageType = 'image/jpeg'; + } + if ($imageType !== 'image/gif') { + $preview_format = $this->config->getSystemValueString('preview_format', ''); + switch ($preview_format) { + case 'webp': + $imageType = 'image/webp'; + break; + case 'avif': + $imageType = 'image/avif'; + break; + default: + } + } + switch ($imageType) { case "image/png": $res = imagepng($this->resource); break; @@ -425,7 +451,7 @@ public function data(): ?string { break; case "image/webp": /** @psalm-suppress InvalidScalarArgument */ - imageinterlace($this->resource, (PHP_VERSION_ID >= 80100 ? true : 1)); + imageinterlace($this->resource, (PHP_VERSION_ID >= 80000 ? true : 1)); $res = imagewebp($this->resource, null, $this->getWebpQuality()); break; case "image/avif": From c622c48f919a2da396be83deccbb072430a39bfe Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Wed, 18 Oct 2023 02:46:05 +0200 Subject: [PATCH 12/15] Remove Licence Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/Preview/AVIF.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/private/Preview/AVIF.php b/lib/private/Preview/AVIF.php index 1e3834bf3964b..ea8abb9a4d353 100644 --- a/lib/private/Preview/AVIF.php +++ b/lib/private/Preview/AVIF.php @@ -2,27 +2,6 @@ declare(strict_types=1); -/** - * @copyright Copyright (c) 2018 Roeland Jago Douma - * - * @author Roeland Jago Douma - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - */ namespace OC\Preview; use OCP\Files\FileInfo; From e8b23b528afce24adfe97a1f3fa1527f37bfe6b3 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Wed, 18 Oct 2023 02:48:46 +0200 Subject: [PATCH 13/15] Add AVIF Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/Preview/Generator.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index 4e4571f08570d..d7c9612bd31d2 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -651,6 +651,8 @@ private function getExtension($mimeType) { return 'png'; case 'image/jpeg': return 'jpg'; + case 'image/avif': + return 'avif'; case 'image/gif': return 'gif'; default: From 45b559671edcd54db698d220e7f432ad5b9e5db5 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Wed, 18 Oct 2023 02:56:21 +0200 Subject: [PATCH 14/15] Set default AVIF quality to 50 Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/private/legacy/OC_Image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/legacy/OC_Image.php b/lib/private/legacy/OC_Image.php index 8b5cedfcbde3a..e4b18189fab4d 100644 --- a/lib/private/legacy/OC_Image.php +++ b/lib/private/legacy/OC_Image.php @@ -55,7 +55,7 @@ class OC_Image implements \OCP\IImage { // Default quality for jpeg images protected const DEFAULT_JPEG_QUALITY = 80; protected const DEFAULT_WEBP_QUALITY = 80; - protected const DEFAULT_AVIF_QUALITY = 80; + protected const DEFAULT_AVIF_QUALITY = 50; /** @var false|resource|\GdImage */ protected $resource = false; // tmp resource. From e5ac2203a5125084de12c014ebd9d05a77bac51e Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:42:42 +0200 Subject: [PATCH 15/15] Add avif Signed-off-by: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> --- lib/public/Collaboration/Reference/LinkReferenceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/public/Collaboration/Reference/LinkReferenceProvider.php b/lib/public/Collaboration/Reference/LinkReferenceProvider.php index d41c1160c7c07..14ab0b3db0859 100644 --- a/lib/public/Collaboration/Reference/LinkReferenceProvider.php +++ b/lib/public/Collaboration/Reference/LinkReferenceProvider.php @@ -60,7 +60,8 @@ class LinkReferenceProvider implements IReferenceProvider { 'image/jpeg', 'image/gif', 'image/svg+xml', - 'image/webp' + 'image/webp', + 'image/avif' ]; /**