Thumbnail quality setting is wrong/undocumented

Hi!

Following a thread on GitHub regarding the jpeg_quality setting of the previewgenerator app.

I found that the jpeg_quality setting is not used by Nextcloud (files/gallery) itself, so if you do not use the previewgenerator, all thumbnails and previews will be generated at quality level 90.

As far as I can tell by the source code, this snippet is used to set the quality level:

protected function getJpegQuality() {
		$quality = $this->config->getAppValue('preview', 'jpeg_quality', 90);
		if ($quality !== null) {
			$quality = min(100, max(10, (int) $quality));
		}
		return $quality;
	}

It is clear that Nexctcloud core is looking for a very similar jpeg_quality setting as the one used by the previewgenerator app. This is not , however, set in the config.php file. It has to be set with the following occ command:

occ config:app:set preview jpeg_quality --value="60"

Is this a bug, a feature, or a mistake in previewgenerator app or in the Nextcloud core? This setting (for the Nextcloud core) is not documented anywhere as far as I can tell.

2 Likes

Did no one else experience this?

It is true what you say, and was good investigated here:

1 Like

Actually, I think there is a difference, and that is also perahps wrong on the code from your link.

They mention the following code to change JPEG quality setting:
occ config:system:set jpeg_quality --value 60

whereas I believe from my research that the correct setting should be:
occ config:app:set preview jpeg_quality --value="60"

The reason for this is in the code snippet where you can see the Nextcloud is looking for the value jpeg_quality in the app setting for preview.

$quality = $this->config->getAppValue('preview', 'jpeg_quality', 90);
1 Like

Could be. I see you already comment original Post, thanks! :+1:
Also I set it as was written in the article and newly generated jpegs are dramatically smaller in compare to older with the same resolution. Seems those settings are working somehow.

Yes, the jpegs are smaller because the original settings in the article affects the third party app “previewgenerator”. So while you run that in the background to pre-render previews that setting takes effect. However, if you just browse around with the files app, then it will make much larger files.

Ahhhh, this is a difference.

1 Like

Yes. Sorry I wasn’t clear on that.

thanks @anon9582441! good catch