server icon indicating copy to clipboard operation
server copied to clipboard

Being able to choose compression quality

Open Sulfiore opened this issue 9 years ago • 5 comments

Feature request

User type: Logged In or not

User level: Beginners

Issue

It takes about 5 seconds for me, to load a thumbnail the gallery view, and about 10 sec to view a single picture, when I try to view a single pictures all 4 cores are used more than 3/4th

Description of feature / solution to the issue

Is there any way to choose picture preview compression ratio ? Is it possible to disable it ? I think there’s no way to do this, I tried look for it in the source code but I did not find anything

Benefit / value

People would be able to choose the compression ratio they want, e.g. high compression level when the server has high perf CPU and people with slow Internet access can choose low compression level (or even no compression) when the server has a bad CPU and if I know that people have fast Internet access

Are you a developer willing to implement this feature?: Yes but I do not find where IPreview is located

In my opinion, you should test the server on some personal computers with CPUs like two cores pentium as some servers only have atom. I mean that I would not buy an expensive server just to share few pictures of holidays with my family.

Illustration

Here is htop when i load an album with the gallery I used htop to visualise what happens when I load an album with the gallery : capture d ecran 2017-01-17 a 18 05 15

Originally from #194@Gallery

Sulfiore avatar Jan 17 '17 18:01 Sulfiore

Are you a developer willing to implement this feature?: Yes but I do not find where IPreview is located

👍 I can point you to those files.

The files you need to touch are:

  • lib/private/Preview/ and
  • lib/private/legacy/image.php

nickvergessen avatar Jan 18 '17 08:01 nickvergessen

If someone else wants to help, they're welcome

Sulfiore avatar Jan 18 '17 16:01 Sulfiore

Hello, I'm also very interested in disabling the compression because of its bad quality. So I did some research and located the point for optimizing:

/lib/private/legacy/image.php

line 270: $retVal = imagejpeg($this->resource, $filePath);

this calls imagejpeg() with the default jpg quality of 75. According to Stackoverflow GD's compression algorithms are not the best ones. However, with a change to:

line 270: $retVal = imagejpeg($this->resource, $filePath, --$JpgQuality--);

You could use a configurable Quality Setting during jpg creation. 100 would mean no lossy compression and therefore less cpu load but much bigger files.

Sadly I have no idea how to create a configuration variable.

edit: for effect in the gallery you have to change line 322 also:

$res = imagejpeg($this->resource); --> $res = imagejpeg($this->resource, NULL, --$JpgQuality--);

I did an test with quality 100 on my installation and the file size of my example picture changed from 409kB --> 1MB. The scaling quality remains poor and does not the quality enhancement I wished for. but

menaceone avatar Feb 20 '17 13:02 menaceone

If someone else wants to help, he's welcome

Or "she", presumably! ;)

Bugsbane avatar Feb 21 '17 02:02 Bugsbane

"They" made a PR at https://github.com/nextcloud/server/pull/3575

nickvergessen avatar Feb 22 '17 11:02 nickvergessen