-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Introducing the maximum size preview #13674
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
I lost PR #13582, so this is a copy. cc @georgehrke |
Refer to this link for build results (access rights to CI server needed): |
This looks like a nice improvement. I can't seem to get my head around all this logic though. |
Code changes itself seem fine (although I agree that it's a lot changes for one commit 😄) |
Maybe I should have split it in 3 commits. I did move one test and 2 other methods around. As for the logic, you have to start with
|
@@ -100,8 +100,8 @@ public function __construct($user = '', $root = '/', $file = '', $maxX = 1, $max | |||
$this->userView = new \OC\Files\View('/' . $user); | |||
|
|||
//set config | |||
$this->configMaxX = \OC_Config::getValue('preview_max_x', null); | |||
$this->configMaxY = \OC_Config::getValue('preview_max_y', null); | |||
$this->configMaxX = \OC_Config::getValue('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 I ask you to use \OCP\IConfig
?
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, I guess, it's a good time to upgrade all those calls...
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.
\OC::$server->getConfig()->getSystemValue()
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.
or just add ifconfig to the constructor
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 means every call to new Preview()
will need to be updated to include new parameters or am I missing something?
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.
I would go with the \OC::$server->getConfig() right inside this class in the short term.
@georgehrke Please have a look too |
@georgehrke Once you're fine with this I will review. |
@oparoz Isn't 2048x2048 a bit much? That's something you might need for public sharing previews on a high-resolution screen. Wouldn't 512x512 be enough for most use-cases? |
@georgehrke - Phones today have 2k screens, a 512x512 picture on a small, high DPI screen will look tiny. That's the main reason for me to keep it as is. And let's not forget that this is used only for full screen previews. Thumbnails will be much smaller. |
Okay, I can see your point there :) |
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
Refer to this link for build results (access rights to CI server needed): Build result: FAILURE[...truncated 14 lines...] > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10 > git config --add remote.origin.fetch +refs/heads/:refs/remotes/origin/ # timeout=10 > git config remote.origin.url https://github.com/owncloud/core.git # timeout=10Fetching upstream changes from https://github.com/owncloud/core.gitusing GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git8497915014349887160.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse refs/remotes/origin/pr/13674/merge^{commit} # timeout=10 > git rev-parse refs/remotes/origin/origin/pr/13674/merge^{commit} # timeout=10Checking out Revision f045ee672a187a5f53ef1e94558180f4be069c8c (refs/remotes/origin/pr/13674/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f f045ee672a187a5f53ef1e94558180f4be069c8c > git rev-list ee6566d64e5f795732cf9e0a8d9ca2972db6bf14 # timeout=10First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILURESetting status of 07b5402 to FAILURE with url https://ci.owncloud.org/job/pull-request-analyser-ng-simple/10378/ and message: Merged build finished.Test FAILed. |
The inspection completed: 3 new issues, 5 updated code elements |
Failing unit tests are unrelated |
Replaced by #14879 |
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