-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Introducing the maximum size preview #14879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@georgehrke What is your opinion? |
$this->configMaxX = \OC_Config::getValue('preview_max_x', null); | ||
$this->configMaxY = \OC_Config::getValue('preview_max_y', null); | ||
$this->maxScaleFactor = \OC_Config::getValue('preview_max_scale_factor', 2); | ||
$this->configMaxX = \OC::$server->getConfig()->getSystemValue('preview_max_x', 2048); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we maybe modify the constructor to expect some OCP\IConfig
and if null is given fall back to \OC::$server->getConfig()
(edit: and the same for logging)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems doable, but is it the right patch to modify the signature? Wouldn't it be better to introduce that in a PR which can be given as a reference to the change so that people can start modifying their code? cc @MorrisJobke @LukasReschke
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People should never create a \OC\Preview instance directly and use getPreviewManager
anyway.
(but removing all direct creations of \OC\Preview in core should definitely be done in a separate pr. (will take care))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, except that, sometimes, it's not possible to use it as PreviewManager is not yet a true replacement of \OC\Preview
See #12772 for what's missing
But if it's confirmed that the signature change should happen here, I'll do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the right approach, but will conflict greatly with #14857
Maybe you can wait, until that is done, since it is a major rework on the same file aswell ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds reasonable. I'll let you adjust the signature then and will update this PR when you're done.
Code looks good to me otherwise
|
@@ -921,7 +1056,7 @@ public static function post_delete($args, $prefix='') { | |||
* @return bool | |||
*/ | |||
public static function isAvailable(\OC\Files\FileInfo $file) { | |||
if (!\OC_Config::getValue('enable_previews', true)) { | |||
if (!\OC::$server->getConfig()->getSystemValue('enable_previews', true)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will conflict with #14857
Since there were no newly introduced public methods, I just did an extensive preview size test. I'm also forcing a resize since the image provider is not doing it's resizing job properly and since that's what people are going to use the most. I've found that testing the file individually (using the bootstrap) will WIPE your admin's data. Note: It's possible to tweak the preview size and get the test to fail, because of this bug: #14712 |
@georgehrke @MorrisJobke @PVince81 @DeepDiver1975 |
Maybe @icewind1991 and @jancborchardt want to test it as well since this benefits the Gallery apps. |
$file, $this->configMaxX, $this->configMaxY, $scalingUp = false, $this->fileView | ||
); | ||
|
||
if (!($preview instanceof \OC_Image)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the interface please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, thanks.
The first time we're asked to generate a preview we'll generate one of the maximum dimension indicated in the configuration and all future resizing requests will be done on that preview in order to not waste time converting the same file over and over. One of the fixes required for #12465
The inspection completed: 2 new issues, 6 updated code elements |
Refer to this link for build results (access rights to CI server needed): |
Tested and works 👍 |
mentioned issues fixed, works 👍 |
Introducing the maximum size preview
Replaces #13674
Fixes
The problem
You've just uploaded a 100MB TIFF file that you need to share with a restricted audience. Here is what currently happens once the file has been uploaded.
You're starting to get it. Every time a slightly different preview size is asked, a full conversion of that 100MB TIFF to PNG is performed. This is highly inefficient.
Proposed solution
Default size is 2048x2048
The maximum size preview is keeping the aspect ratio of the original and is not upscaled.
It's is immediately stored in the cache with a special
max
tag and size identifiers based on its real size.Every time a preview of a different size is asked, we store it in the cache. This also speeds up operation at the cost of disk space.
This make a huge difference in libraries holding several large files, for people using apps such as the Gallery.
Recreated after the loss of #13582