From 21b8a2863230a9c8bbe8527c4acafe6cd247fb92 Mon Sep 17 00:00:00 2001 From: JanisPlayer <54918417+JanisPlayer@users.noreply.github.com> Date: Thu, 18 May 2023 04:04:14 +0200 Subject: [PATCH] Remove AVIF Benchmark | Understandable settings Unfortunately, it is only worthwhile for 1080p users and would have to be limited until then and even then the utilization is very high. 'memories.image.highres_convert_all_images_formarts_enabled' => 'true', 'memories.image.highres_format' => 'webp', 'memories.image.highres_quality'=> '80', 'memories.image.highres_max_x'=> '6144', 'memories.image.highres_max_y'=> '6144', --- lib/Controller/ImageController.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index 59d55914..03b32b94 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -276,8 +276,8 @@ class ImageController extends GenericApiController $blob = $file->getContent(); // Convert image to JPEG if required - $format = $this->config->getSystemValueString('memories.preview.format', 'false'); - if (!\in_array($mimetype, ['image/png', 'image/webp', 'image/jpeg', 'image/gif'], true) || $format != 'false') { + $highres_enabled = $this->config->getSystemValueString('memories.image.highres_convert_all_images_formarts_enabled', 'false'); + if (!\in_array($mimetype, ['image/png', 'image/webp', 'image/jpeg', 'image/gif'], true) || $highres_enabled == 'true') { [$blob, $mimetype] = $this->getImageJPEG($blob, $mimetype); } @@ -381,7 +381,7 @@ class ImageController extends GenericApiController // Convert to JPEG try { $image->autoOrient(); - $format = $this->config->getSystemValueString('memories.preview.format', 'jpeg'); + $format = $this->config->getSystemValueString('memories.highres_format', 'jpeg'); switch ($format) { case 'jpeg': $format = 'jpeg'; @@ -389,30 +389,30 @@ class ImageController extends GenericApiController case 'webp': $format = 'webp'; break; - case 'avif': - $format = 'avif'; - break; + /*case 'avif': //CPU Benchmark + //$format = 'avif'; + break*/ default: $format = 'jpeg'; } $image->setImageFormat($format); - $quality = (int)$this->config->getSystemValue('memories.preview.quality', '95'); + $quality = (int)$this->config->getSystemValue('memories.image.highres_quality', '95'); if ($quality < 0 || $quality > 100) { //throw Exceptions::Forbidden('Warning: You have set an invalid quality value for image conversion'); } $image->setImageCompressionQuality($quality); // Set maximum width and height - $maxWidth = (int)$this->config->getSystemValue('memories.preview.x', '0'); - $maxHeight = (int)$this->config->getSystemValue('memories.preview.y', '0'); + $maxWidth = (int)$this->config->getSystemValue('memories.image.highres_max_x', '0'); + $maxHeight = (int)$this->config->getSystemValue('memories.image.highres_max_y', '0'); // Get current dimensions $width = (int)$image->getImageWidth(); $height = (int)$image->getImageHeight(); // Calculate new dimensions while maintaining aspect ratio - if($maxWidth != 0 && $maxHeight != 0) { + if ($maxWidth > 0 && $maxHeight > 0) { if ($width > $maxWidth || $height > $maxHeight) { $aspectRatio = $width / $height; if ($width > $height) { @@ -437,8 +437,6 @@ class ImageController extends GenericApiController $mimeTypes = [ 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', - 'png' => 'image/png', - 'gif' => 'image/gif', 'webp' => 'image/webp', 'avif' => 'image/avif', ];