Skip to content
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

Thumbnail rework #646

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Thumbnail rework #646

wants to merge 18 commits into from

Conversation

po5
Copy link
Contributor

@po5 po5 commented Mar 21, 2024

Higher quality and lower filesize thumbnails with cjpeg (provided by mozjpeg for quality or libjpeg-turbo for speed).

Videos in the upload form now have a preview that matches the final thumbnail.

Thumbnails are now used as placeholder while the full-size image is loading on post pages.
Thumbnail stays if the full-size image load fails. If both pics fail, the transparency grid is shown (if enabled).

Videos have two thumbnails, one taken at 30% into the video (the "custom" thumbnail shown in search results), and one of the first frame (the thumbnail used as a preroll on post pages).

Images are now resized in RGB even for indexed color PNGs. It would lead to ugly dithering that also hurt compression.
Before
image
After
image

Thumbnail filenames are prefixed with sample_ to make it clear to the user they didn't download the original image.

po5 added 18 commits March 21, 2024 21:58
Indexed color PNGs would use their palette during scaling, leading to
very ugly dithering.
Convert to RGB32/RGB24, depending on if we intend to keep transparency.
For RGB24 this sets background color from the palette if there was one,
black otherwise although that may be undesirable.
Will have to find a way to fall back to a nicer color, or always use
the same color that we configure ourselves.
Fallback cascade: original content, thumbnail, transparency grid
Implementation is very ugly but handles all cases nicely.
Saving custom thumbnails separately allows us to display them in search
results etc while also displaying a thumbnail of the final content
during loading.
I can see the intent, sadly this was always broken in the case where the
post already has a custom thumbnail from initial load, and we don't drag
any new files. It did not actually remove the existing thumbnail.
Before 12c4542 it would actually crash,
but this now makes it behave as expected.
Also properly syncs internal state with what's displayed to the user.
@po5 po5 mentioned this pull request Mar 28, 2024
background-size: 20px 20px
img
repeating-linear-gradient(45deg, $window-color, $window-color 10px, #e6e6e6 10px, #e6e6e6 20px)
img, video
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@po5 po5 marked this pull request as draft May 19, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants