option to use imagick in preview generation with extended opts #1
This PR is a PoC that introduces the option of using Imagick for JPEG images in the previews engine.
See this blog post.
There are two main areas where we could try to work to optimize tis
This is an attempt at improving this situation through a combination of
This PR would be part number one of said attempt.
The main attractive of imagick in native multithreaded execution if compiled with openMP (the default at least in Debian).
Since we are not interested in implementing everything from scratch but only try to improve the most performance sensitive areas, I have extended
Since there are concerns about using imagick at all and in order to allow flexibility this new mechanism is optional. It can be enabled and tweaked through config options.
Generate the previews as fast as possible without sacrificing much quality.
I tested these changes with a dataset comprised of 1.5GiB of high quality photos (~100 x 15MiB photos) on a 16 core x86 machine with 64MiB of RAM.
For the reasons stated above, I ran the tests with the following configuration
All the files are already uploaded. The preview cache is cleaned every run with
In Imagick we are using a CATROM filter.
(*) Default settings: 4096x4096 Max preview, all sizes enabled
The multi-process tests (bottom half) are run using the modified Preview Generator -> nachoparker/previewgenerator#1
Imagick can outperform GD while retaining decent quality mainly due to the fact that is multi-threaded. Still the big bottleneck is in the PHP non native part. In order to improve that something like nextcloud#14953 would need to be implemented, or maybe try to optimize the current Previews code flow.
Since this is the case, better results are achieved by using the "multi-process" approach (nachoparker/previewgenerator#1). Even without server modifications, using the traditional GD method we can achieve a 4x speed boost, which would be 5x with Imagick (with the proposed settings).
Just configuring the Preview Generator properly will imply a 4x speed boost and lots of space saved without any other changes.
JPEG quality barely affects performance, but it mostly only affects storage space.
With these changes the user has more options to tweak performance according to their preferences and how powerful their machine is.
Signed-off-by: nachoparker firstname.lastname@example.org
This was referenced
Jun 28, 2019
I really like this. Your configuration for preview generator and preview sizes are doing wonders on my setup! Thanks! Getting imagick in Nextcloud would be nice, but I understand it may be tough. I would still like to see it as first-class citizen (of course, under
I only did basic changes in order to test the improvement in performance, but in order for it to be merged it will probably be tidied up a bit, at least reorganized into separate files and so on.
Let's keep the conversation in the NC PR. Will block comments here