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',pull/653/head
parent
e613076cc5
commit
21b8a28632
|
@ -276,8 +276,8 @@ class ImageController extends GenericApiController
|
||||||
$blob = $file->getContent();
|
$blob = $file->getContent();
|
||||||
|
|
||||||
// Convert image to JPEG if required
|
// Convert image to JPEG if required
|
||||||
$format = $this->config->getSystemValueString('memories.preview.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) || $format != 'false') {
|
if (!\in_array($mimetype, ['image/png', 'image/webp', 'image/jpeg', 'image/gif'], true) || $highres_enabled == 'true') {
|
||||||
[$blob, $mimetype] = $this->getImageJPEG($blob, $mimetype);
|
[$blob, $mimetype] = $this->getImageJPEG($blob, $mimetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ class ImageController extends GenericApiController
|
||||||
// Convert to JPEG
|
// Convert to JPEG
|
||||||
try {
|
try {
|
||||||
$image->autoOrient();
|
$image->autoOrient();
|
||||||
$format = $this->config->getSystemValueString('memories.preview.format', 'jpeg');
|
$format = $this->config->getSystemValueString('memories.highres_format', 'jpeg');
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
case 'jpeg':
|
case 'jpeg':
|
||||||
$format = 'jpeg';
|
$format = 'jpeg';
|
||||||
|
@ -389,30 +389,30 @@ class ImageController extends GenericApiController
|
||||||
case 'webp':
|
case 'webp':
|
||||||
$format = 'webp';
|
$format = 'webp';
|
||||||
break;
|
break;
|
||||||
case 'avif':
|
/*case 'avif': //CPU Benchmark
|
||||||
$format = 'avif';
|
//$format = 'avif';
|
||||||
break;
|
break*/
|
||||||
default:
|
default:
|
||||||
$format = 'jpeg';
|
$format = 'jpeg';
|
||||||
}
|
}
|
||||||
$image->setImageFormat($format);
|
$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) {
|
if ($quality < 0 || $quality > 100) {
|
||||||
//throw Exceptions::Forbidden('Warning: You have set an invalid quality value for image conversion');
|
//throw Exceptions::Forbidden('Warning: You have set an invalid quality value for image conversion');
|
||||||
}
|
}
|
||||||
$image->setImageCompressionQuality($quality);
|
$image->setImageCompressionQuality($quality);
|
||||||
|
|
||||||
// Set maximum width and height
|
// Set maximum width and height
|
||||||
$maxWidth = (int)$this->config->getSystemValue('memories.preview.x', '0');
|
$maxWidth = (int)$this->config->getSystemValue('memories.image.highres_max_x', '0');
|
||||||
$maxHeight = (int)$this->config->getSystemValue('memories.preview.y', '0');
|
$maxHeight = (int)$this->config->getSystemValue('memories.image.highres_max_y', '0');
|
||||||
|
|
||||||
// Get current dimensions
|
// Get current dimensions
|
||||||
$width = (int)$image->getImageWidth();
|
$width = (int)$image->getImageWidth();
|
||||||
$height = (int)$image->getImageHeight();
|
$height = (int)$image->getImageHeight();
|
||||||
|
|
||||||
// Calculate new dimensions while maintaining aspect ratio
|
// Calculate new dimensions while maintaining aspect ratio
|
||||||
if($maxWidth != 0 && $maxHeight != 0) {
|
if ($maxWidth > 0 && $maxHeight > 0) {
|
||||||
if ($width > $maxWidth || $height > $maxHeight) {
|
if ($width > $maxWidth || $height > $maxHeight) {
|
||||||
$aspectRatio = $width / $height;
|
$aspectRatio = $width / $height;
|
||||||
if ($width > $height) {
|
if ($width > $height) {
|
||||||
|
@ -437,8 +437,6 @@ class ImageController extends GenericApiController
|
||||||
$mimeTypes = [
|
$mimeTypes = [
|
||||||
'jpeg' => 'image/jpeg',
|
'jpeg' => 'image/jpeg',
|
||||||
'jpg' => 'image/jpeg',
|
'jpg' => 'image/jpeg',
|
||||||
'png' => 'image/png',
|
|
||||||
'gif' => 'image/gif',
|
|
||||||
'webp' => 'image/webp',
|
'webp' => 'image/webp',
|
||||||
'avif' => 'image/avif',
|
'avif' => 'image/avif',
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue