Skip to content

Previews with aspect ratio need to be properly cached #13516

Closed

Description

@oparoz

Current situation

Currently, the code in the Preview class contains this in the isCachedBigger() method:

// in order to not loose quality we better generate aspect preserving previews from the original file
if ($this->keepAspect) {
    return false;
}

and even if this is commented out, the class will never return a cached copy of a preview if the client is asking for a smaller preview which keeps the aspect ratio as the code further down doesn't look for it.

Why is this a problem?

Let's say you're storing a 25MB TIFF and want to see it full screen via the Gallery app.
The app asks for a 1233x1487 preview and 30 seconds later the cache stores it as 1233-1487-with-aspect.png.
Now resize your screen slightly and ask for a full screen preview again.
You'll have to wait the full 30 seconds again to get a 932-1487-with-aspect.png preview

Multiply this scenario by the number of window configurations which are going to be used to watch a large screen preview and that thumbnail folder is going to get filled with a lot of similar previews and a lot of CPU cycles is going to get wasted.

Next steps

  • What's the problem with resizing a cached "with-aspect" preview?

If the problem doesn't exist any more

  • Update the cache checking methods

cc @georgehrke @DeepDiver1975

Activity

  1. georgehrke commented on Jan 20, 2015

    @georgehrke
    Contributor

    cc'ing @icewind1991 as he introduced the '-with-aspect' name-scheme for gallery

  2. oparoz commented on Jan 20, 2015

    @oparoz
    ContributorAuthor

    And is there documentation somewhere regarding some of the design decisions which has been made regarding resizing and caching? For instance, on a few occasions, only width < maxX is checked. Is that because previews are expected to be square within OC core?

  3. oparoz commented on Jan 20, 2015

    @oparoz
    ContributorAuthor

    OK, 2 reasons this is failing are:

    • The dimensions of the preview may not match maxX and maxY. So we have a 700x350 preview stored as 1233x1487-with-aspect
    • maxX and maxY are based on the window size, so with today's variety of screen dimensions, this leads to many different aspect ratios and comparing them will often fail
  4. oparoz commented on Jan 20, 2015

    @oparoz
    ContributorAuthor

    I had a look at the process and there are 2 solutions to the window resizing problem:

    It's possible to combine both for maximum effect.

    I still don't know why it's bad to resize a "with-aspect" preview.

  5. oparoz commented on Jan 22, 2015

    @oparoz
    ContributorAuthor

    I'm marking this as a duplicate of #12465 since solving that problem will make this one less relevant.
    The potential fix is in #13674

    Having size categories can be another issue and PR.

  6. locked as resolved and limited conversation to collaborators on Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions